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
46
votes
23
answers
8k
views
Unflatten an Array
This challenge was inspired by a question on Mathematica.SE.
Say you've got a nested list/array of some arbitrary structure (the lists at each level don't necessarily have the same length). For ...
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 ...
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 ...
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:
...
36
votes
36
answers
8k
views
Flatten the Array! [duplicate]
In this challenge, your task is to create a program which takes in a nested array and returns a single-dimensional flattened array. For Example [10,20,[30,[40]],50] ...
33
votes
10
answers
2k
views
Build a nest
The challenge is simple: write a program or function that, when given a finite non-negative integer, outputs a nested array.
The rules
Your code must produce a unique valid nested array for every ...
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 ...
27
votes
27
answers
3k
views
Pad a jagged array to be square
Given a 2-dimensional jagged array and a fill value, pad the array in both dimensions with the fill value to ensure that it is square and not jagged (i.e., all rows are the same length, and that ...
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 ...
27
votes
7
answers
1k
views
Decode the Void
A void list is a list that at no level contains any non-list objects. Or if you prefer a recursive definition
The empty list is void
A list containing only other void lists is void
All void lists ...
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 ...
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 ...
23
votes
17
answers
2k
views
Reconstruct a recursively prime-encoded integer
Recursively prime-encoded integers
Consider \$11681169775023850 = 2 \times 5 \times 5 \times 42239 \times 5530987843\$. This isn't a nice prime factorisation, as \$42239\$ and \$5530987843\$ make it ...
23
votes
19
answers
2k
views
Deep Search a List
For this challenge, a list is considered valid if and only if it consists entirely of integers and valid lists (recursive definitions \o/). For this challenge, given a valid list and an integer, ...
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 ...