Questions tagged [ragged-list]
A ragged list, also called a jagged list, is a list where each element can either be some terminal type (e.g. an integer) or another ragged list.
44 questions
27
votes
18
answers
1k
views
Scan a ragged list
hgl has a "scan" function called sc. What it does in general is a little bit abstract, so we will just talk about one specific way you can use it.
If we ...
22
votes
28
answers
2k
views
Collect the elements of an array
Add++, the Language of the Month, has the "collect" builtin as BC. Your task is to implement this builtin.
Consider a non-empty array, where each element ...
21
votes
23
answers
3k
views
Multiply numbers by their depth
Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested.
For example, with the list ...
19
votes
20
answers
959
views
Minimum depth of a ragged list
As input you will be given a ragged list of positive integers containing at least one integer at some level. For example:
[[],[[1,2,[3]]],[]]
You should output ...
23
votes
24
answers
1k
views
Find the maximum length in a ragged list
Given a ragged list of positive integers find the size of the largest list contained somewhere in it.
For example:
[1,[1,[8,2,[1,2],5,4,9]],2,[],3]
Here the answer ...
16
votes
10
answers
2k
views
Zip ragged lists
In Haskell (and probably some other languages or something) zip is a function which takes two lists, and produces a list of tuples by pairing elements at the same ...
23
votes
33
answers
4k
views
Make a list flat
Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it ...
4
votes
2
answers
482
views
Bracket Depth List
Challenge
Your challenge is simple, calculate the depth of each matching brackets in the given input e.g. (()()(()))->...
20
votes
12
answers
2k
views
Search the deepest depths of an array
Given a ragged array, find the length of the largest subarray that contains the depth of that subarray. The base array layer has a depth of 0.
Here is an example:
...
39
votes
55
answers
12k
views
Determine the depth of an array
A simple challenge for your Monday evening (well, or Tuesday morning in the other half of the world...)
You're given as input a nested, potentially ragged array of positive integers:
...
40
votes
12
answers
3k
views
Re-name all identifiers to a single letter
Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which ...
18
votes
21
answers
3k
views
cadaddadadaddddaddddddr - linked list accessing
Create a function (or closest equivalent, or full program) that takes an list of some datatype (your choice) that may be nested and a string (in either order), and generalizes the lisp c[ad]+r ...
22
votes
24
answers
3k
views
Iteratively delete a list
Say I have a ragged list, like:
[
[1, 2],
[3,
[4, 5]
]
]
And I want to iterate over each item and delete it one-by-one. However, I don't know the ...
18
votes
26
answers
2k
views
Is it a valid list?
Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list.
A list is either:
...
13
votes
12
answers
456
views
Products all the way down
You are probably familiar with the Cartesian product. It takes two lists and creates a list of all pairs that can be made from an element of the first and an element from the second:
\$
\left[1,2\...