diff options
| author | Andrey Orst <andreyorst@gmail.com> | 2020-11-13 22:54:12 +0300 |
|---|---|---|
| committer | Andrey Orst <andreyorst@gmail.com> | 2020-11-13 22:54:12 +0300 |
| commit | 1b309ac016d806d2f9b44540ed5020f5c60c4256 (patch) | |
| tree | fca18ab2e0153a1462da473cd2fe5c9cc0de6a69 /README.org | |
| parent | 8493fa29b1848bf93e899e8930c6e8c1c723eece (diff) | |
fix(core): refactoring
- Rename `fn*` to `defn`, `fn&` to `fn+`.
- Do not use `fn+` in the core at all, provide it for convenience.
- Fix bug in `filter` due to incorrect `cons` implementation.
- Update `seq` and `eq` functions in macros
Diffstat (limited to 'README.org')
| -rw-r--r-- | README.org | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -125,12 +125,12 @@ Returns a function of fixed amount of arguments by doing runtime dispatch based Capable of producing multi-arity functions: #+begin_src fennel - (fn* square "square number" [x] (^ x 2)) + (defn square "square number" [x] (^ x 2)) (square 9) ;; => 81.0 (square 1 2) ;; => error - (fn* range + (defn range "Returns increasing sequence of numbers from `lower' to `upper'. If `lower' is not provided, sequence starts from zero. Accepts optional `step'" @@ -150,11 +150,11 @@ Capable of producing multi-arity functions: Both variants support up to one arity with =& more=: #+begin_src fennel - (fn* vec [& xs] xs) + (defn vec [& xs] xs) (vec 1 2 3) ;; => [1 2 3] - (fn* add + (defn add "sum two or more values" ([] 0) ([a] a) @@ -172,7 +172,7 @@ One extra capability of =fn*= supports the same semantic as =def= regarding name #+begin_src fennel (local ns {}) - (fn* ns.plus + (defn ns.plus ([] 0) ([x] x) ([x y] (+ x y)) @@ -203,29 +203,29 @@ This is possible because =fn*= separates the namespace part from the function na See =core.fnl= for more examples. -** =fn&= +** =fn+= Works similarly to Fennel's =fn=, by creating ordinary function without arity semantics, except does the namespace automation like =fn*=, and has the same order of arguments as the latter: #+begin_src fennel (local ns {}) ;; module & file-local functions - (fn& ns.double + (fn+ ns.double "double the number" [x] (* x 2)) - (fn& ns.triple + (fn+ ns.triple [x] (* x 3)) ;; no namespace, file-local function - (fn& quadruple + (fn+ quadruple [x] (* x 4)) ;; anonymous file-local function - (fn& [x] (* x 5)) + (fn+ [x] (* x 5)) ns #+end_src |