33 lines
488 B
Fennel
33 lines
488 B
Fennel
;;; std.fnl --- A small standard library
|
|
|
|
;;; Commentary:
|
|
;; Porting a few functions that I'm used to from other Lisps.
|
|
|
|
;;; Code:
|
|
|
|
(var std {})
|
|
|
|
;;;
|
|
;; Functions
|
|
|
|
(fn std.zero? [n]
|
|
(= 0 n))
|
|
|
|
(fn std.fn? [f]
|
|
(= (type f) :function))
|
|
|
|
(fn std.s-empty? [s]
|
|
(or (= nil s)
|
|
(= "" s)))
|
|
|
|
(fn std.s-split [s sep]
|
|
(var t {})
|
|
(let [sep (or sep "%s")
|
|
re (.. "([^" sep "]+)")]
|
|
(each [str (string.gmatch s re)]
|
|
(table.insert t str))
|
|
t))
|
|
|
|
std
|
|
;;; std.fnl ends here
|