get-in (ported from Clojure)

by Ricardo “Rudxain” Fernández Serrata

Version 1 (August 28, 2022)

Download (66 downloads)

Allows flows to access any value in a nested (tree) container at runtime (dynamic), at any depth. Mixed containers are also supported.

Suppose this flow is a function named "gi". This is a table of identities:
x = gi(x)
x = gi(x, any_falsy_value)
x[k] = gi(x, [k])

x[k_0][k_1][k_2]... [k_N] = gi(x, [k_0, k_1, k_2, ... k_N])

x[0][1][2]... [N] = gi(x, N+1)
x[0][1][2]... [N-1] = gi(x, N)

For better performance (and to guarantee that the loop will halt if Infinity is used) when x becomes null (or it's already null) the loop breaks

LICENSE: https://unlicense.org

JS port: https://gist.github.com/Rudxain/370f6d6e8fb7571f120c53d59c375ac5

4.0 average rating from 2 reviews

5 stars
1
4 stars
0
3 stars
1
2 stars
0
1 star
0
Reports
0

Rate and review within the app in the Community section.