From 1b309ac016d806d2f9b44540ed5020f5c60c4256 Mon Sep 17 00:00:00 2001 From: Andrey Orst Date: Fri, 13 Nov 2020 22:54:12 +0300 Subject: 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 --- README.org | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'README.org') diff --git a/README.org b/README.org index 56356c1..53b5ab7 100644 --- a/README.org +++ b/README.org @@ -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 -- cgit v1.2.3