JanetDocsPlaygroundI'm feeling luckyGitHub sign in

walk



    function
    boot.janet on line 1306, column 1

    (walk f form)

    Iterate over the values in ast and apply `f` to them. Collect the 
    results in a data structure. If ast is not a table, struct, array, 
    or tuple, returns form.


1 exampleSign in to add an example
Loading...
(defn walker
  `Simple walker function, that prints non-sequential 
   members of the form or prints "Sequence" and walks 
   recursively sequential members of the tree.` 
  [form] 
  (if (or (indexed? form) (dictionary? form))
    (do (print "Sequence")
        (walk walker form))
    (print form)))

(walk walker [[[[0 1 3]] 16 7 [3 [3 5]] 3 4] 1 [3 4]])

# Prints
# Sequence
# Sequence
# Sequence
# 0
# 1
# 3
# 16
# 7
# Sequence
# 3
# Sequence
# 3
# 5
# 3
# 4
# 1
# Sequence
# 3
# 4
pepePlayground