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
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 ...
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 ...
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 ...
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:
...
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 ...
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 ...
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 ...
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:
...
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:
...
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 ...
42
votes
48
answers
6k
views
Is it true? Ask Jelly!
Background
Inspired by Octave's (and, by extension, MATL's) very convenient interpretation of truthy/falsy matrices, Jelly got the Ȧ (Octave-style all) atom.
Ȧ takes an array as input and returns 1 ...
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 ...
31
votes
18
answers
3k
views
Gödel encoding - Part I
Related but different.
Part II
Taken from the book: Marvin Minsky 1967 – Computation:
Finite and Infinite Machines, chapter 14.
Background
As the Gödel proved, it is possible to encode with a unique ...
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 ...
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 ...