Carp/core/Filepath.carp
2018-11-26 21:19:41 +01:00

13 lines
337 B
Plaintext

(defmodule Filepath
(use Array)
(doc dir-from-path "Removes the file-name part of a path to a file.")
(defn dir-from-path [path]
(let [segments (split-by path &[\/])
n (dec (length &segments))
without-last (prefix-array &segments n)]
(concat &(copy-map &(fn [s] (str* s "/")) &without-last))))
)