JanetDocsPlaygroundI'm feeling luckyGitHub sign in
# foo.txt is a file with contents "hello\nworld\n". (slurp "foo.txt") # => @"hello\nworld\n" (string/split "\n" (slurp "foo.txt")) # => @["hello" "world" ""] (defn slurp-lines [path] (string/split "\n" (slurp path))) (slurp-lines "foo.txt") # => @["hello" "world" ""] (string/join @["hello" "world" ""] "\n") # => "hello\nworld\n" (spit "foo2.txt" (string/join @["hello" "world" ""] "\n")) # The contents of foo.txt and foo2.txt are now identical. (defn spit-lines [path lines] (spit path (string/join lines "\n"))) (spit-lines "foo3.txt" (slurp-lines "foo.txt")) # The contents of foo.txt and foo3.txt are now identical.