mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-05 04:44:12 +03:00
13 lines
337 B
Plaintext
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))))
|
|
|
|
)
|