JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

prewalk

core-api


    function
    boot.janet on line 1490, column 1

    (prewalk f form)

    Similar to `postwalk`, but do pre-order traversal.


1 exampleSign in to add an example
Loading...
# Since table/clone produces a shallow copy and composing freeze and thaw makes everything mutable/immutable
(defn deep-clone [ds]
  (prewalk
    |(cond
       (table? $) (table/clone $)
       (array? $) (array/slice $)
       (buffer? $) (buffer/slice $)
       $)
  ds))
# CalebF wrote this: https://janet.zulipchat.com/#narrow/channel/409517-help/topic/table.2Fclone.20doesn.27t.20make.20a.20deep.20copy.3F/near/617675442
veqqqPlayground