diff options
Diffstat (limited to 'js/scripting-lang/scratch_tests/flatten_scrap.txt')
-rw-r--r-- | js/scripting-lang/scratch_tests/flatten_scrap.txt | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/js/scripting-lang/scratch_tests/flatten_scrap.txt b/js/scripting-lang/scratch_tests/flatten_scrap.txt deleted file mode 100644 index e5d5c96..0000000 --- a/js/scripting-lang/scratch_tests/flatten_scrap.txt +++ /dev/null @@ -1,25 +0,0 @@ -/* Problem: Flatten nested tables */ -nested : { - level1: { - a: {value: 1}, - b: {value: 2} - }, - level2: { - c: {value: 3} - } -}; - -/* Recursive flattening function */ -flatten : table -> - when (t.has table "value") is - true then table - _ then reduce @t.merge {} (map @flatten_entry table); - -flatten_entry : entry -> - when (t.has entry "value") is - true then entry - _ then flatten entry; - -/* Apply flattening */ -flat : flatten nested; -/* Result: {a: {value: 1}, b: {value: 2}, c: {value: 3}} */ |