From 4683e3b721ca32ab8a464306f9b6753b2e5a8ec4 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 24 Apr 2021 17:38:11 -0300 Subject: Add po files for new TILs, update whitespace of others --- .../_tils/2021-04-24-clojure-auto-curry.po | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po (limited to 'locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po') diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po new file mode 100644 index 0000000..67ff1b4 --- /dev/null +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -0,0 +1,127 @@ +# +msgid "" +msgstr "" + +msgid "title: Clojure auto curry" +msgstr "" + +msgid "date: 2021-04-24" +msgstr "" + +msgid "layout: post" +msgstr "" + +msgid "lang: en" +msgstr "" + +msgid "ref: clojure-auto-curry" +msgstr "" + +msgid "" +"A simple macro defined by [Loretta " +"He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " +"create Clojure functions that are curried on all arguments, relying on " +"Clojure's multi-arity support:" +msgstr "" + +msgid "" +"(defmacro defcurry\n" +" [fname args & body]\n" +" (let [partials (map (fn [n]\n" +" `(~(subvec args 0 n) (partial ~fname ~@(take n args))))\n" +" (range 1 (count args)))]\n" +" `(defn ~fname\n" +" (~args ~@body)\n" +" ~@partials)))\n" +msgstr "" + +msgid "A naive `add` definition, alongside its usage and macroexpansion:" +msgstr "" + +msgid "" +"user=> (defcurry add\n" +" [a b c d e]\n" +" (+ 1 2 3 4 5))\n" +"#'user/add\n" +"\n" +"user=> (add 1)\n" +"#object[clojure.core$partial$fn__5857 0x2c708440 \"clojure.core$partial$fn__5857@2c708440\"]\n" +"\n" +"user=> (add 1 2 3 4)\n" +"#object[clojure.core$partial$fn__5863 0xf4c0e4e \"clojure.core$partial$fn__5863@f4c0e4e\"]\n" +"\n" +"user=> ((add 1) 2 3 4 5)\n" +"15\n" +"\n" +"user=> (((add 1) 2 3) 4 5)\n" +"15\n" +"\n" +"user=> (use 'clojure.pprint)\n" +"nil\n" +"\n" +"user=> (pprint\n" +" (macroexpand\n" +" '(defcurry add\n" +" [a b c d e]\n" +" (+ 1 2 3 4 5))))\n" +"(def\n" +" add\n" +" (clojure.core/fn\n" +" ([a b c d e] (+ 1 2 3 4 5))\n" +" ([a] (clojure.core/partial add a))\n" +" ([a b] (clojure.core/partial add a b))\n" +" ([a b c] (clojure.core/partial add a b c))\n" +" ([a b c d] (clojure.core/partial add a b c d))))\n" +"nil\n" +msgstr "" + +msgid "" +"This simplistic `defcurry` definition doesn't support optional parameters, " +"multi-arity, `&` rest arguments, docstrings, etc., but it could certainly " +"evolve to do so." +msgstr "" + +msgid "" +"I like how `defcurry` is so short, and abdicates the responsability of doing" +" the multi-arity logic to Clojure's built-in multi-arity support. Simple and" +" elegant." +msgstr "" + +msgid "Same Clojure as before, now with auto-currying via macros." +msgstr "" + +msgid "Comparison with Common Lisp" +msgstr "" + +msgid "My attempt at writing an equivalent for Common Lisp gives me:" +msgstr "" + +msgid "" +"(defun curry-n (n fn)\n" +" (if (= 0 n)\n" +" (funcall fn)\n" +" (lambda (&rest rest)\n" +" (curry-n (something n) fn))))\n" +"\n" +"(defun add (a b c d e)\n" +" (curry-n\n" +" (length '(a b c d e))\n" +" (lambda (&rest rest)\n" +" (apply #'+ rest))))\n" +msgstr "" + +msgid "" +"Without built-in multi-arity support, we have to do more work, like tracking" +" the number of arguments consumed so far. That is, without dependending on " +"any library, sticking to ANSI Common Lisp." +msgstr "" + +msgid "" +"This also require `funcall`s, since we return a `lambda` that doesn't live " +"in the function namespace." +msgstr "" + +msgid "" +"Like the Clojure one, it doesn't support optional parameters, `&rest` rest " +"arguments, docstrings, etc., but it also could evolve to do so." +msgstr "" -- cgit v1.2.3 From b7bc24827c15e802c867eefdc562fab0db1b49af Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 24 Apr 2021 17:50:22 -0300 Subject: Proofread TIL on CLOS --- ...order-parameterization-of-a-generic-function.md | 4 +-- .../_tils/2021-04-24-clojure-auto-curry.po | 42 ++++++++++++++-------- ...order-parameterization-of-a-generic-function.po | 39 +++++++++++++------- .../_tils/2021-04-24-clojure-auto-curry.po | 42 ++++++++++++++-------- ...order-parameterization-of-a-generic-function.po | 39 +++++++++++++------- .../_tils/2021-04-24-clojure-auto-curry.po | 42 ++++++++++++++-------- ...order-parameterization-of-a-generic-function.po | 39 +++++++++++++------- 7 files changed, 164 insertions(+), 83 deletions(-) (limited to 'locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po') diff --git a/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.md b/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.md index 67a6799..eb19b38 100644 --- a/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.md +++ b/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.md @@ -98,7 +98,7 @@ Combining the order of inheritance with generic functions with multiple argument ``` CLOS has to make a choice between the first and the second definition of `yet-another-fn`, but its choice is just a heuristic. -What if we want to the choice to be based on the second argument first? +What if we want the choice to be based on the second argument, instead of the first? For that, we use the `:argument-precedence-order` option when declaring a generic function: @@ -126,7 +126,7 @@ Since the dispatch function is required, there is no need for a default behaviou Making the argument precedence order configurable for generic functions but not for class definitions makes a lot of sense. When declaring a class, we can choose the precedence order, and that is about it. -But when defining a generic function, the order of argumentws is more important to the function semantics, and the argument precedence being left-to-right is just the default behaviour. +But when defining a generic function, the order of arguments is more important to the function semantics, and the argument precedence being left-to-right is just the default behaviour. One shouldn't change the order of arguments of a generic function for the sake of tailoring it to the CLOS priority ranking algorithm, but doing it for a class definition is just fine. diff --git a/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 67ff1b4..67c4f2e 100644 --- a/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -96,20 +96,6 @@ msgstr "" msgid "My attempt at writing an equivalent for Common Lisp gives me:" msgstr "" -msgid "" -"(defun curry-n (n fn)\n" -" (if (= 0 n)\n" -" (funcall fn)\n" -" (lambda (&rest rest)\n" -" (curry-n (something n) fn))))\n" -"\n" -"(defun add (a b c d e)\n" -" (curry-n\n" -" (length '(a b c d e))\n" -" (lambda (&rest rest)\n" -" (apply #'+ rest))))\n" -msgstr "" - msgid "" "Without built-in multi-arity support, we have to do more work, like tracking" " the number of arguments consumed so far. That is, without dependending on " @@ -125,3 +111,31 @@ msgid "" "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " "arguments, docstrings, etc., but it also could evolve to do so." msgstr "" + +msgid "" +"(defun curry-n (n fn)\n" +" (if (= 0 n)\n" +" (funcall fn)\n" +" (lambda (&rest rest)\n" +" (curry-n (something n) fn))))\n" +"\n" +"(defun add (a b c d e)\n" +" (curry-n\n" +" (length '(a b c d e))\n" +" (lambda (&rest rest)\n" +" (apply #'+ rest))))\n" +msgstr "" + +#~ msgid "" +#~ "(defun curry-n (n fn)\n" +#~ " (if (= 0 n)\n" +#~ " (funcall fn)\n" +#~ " (lambda (&rest rest)\n" +#~ " (curry-n (something n) fn))))\n" +#~ "\n" +#~ "(defun add (a b c d e)\n" +#~ " (curry-n\n" +#~ " (length '(a b c d e))\n" +#~ " (lambda (&rest rest)\n" +#~ " (apply #'+ rest))))\n" +#~ msgstr "" diff --git a/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index b773879..4ca9625 100644 --- a/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -120,12 +120,6 @@ msgid "" ":FIRST-ARG-SPECIALIZED\n" msgstr "" -msgid "" -"CLOS has to make a choice between the first and the second definition of " -"`yet-another-fn`, but its choice is just a heuristic. What if we want to the" -" choice to be based on the second argument first?" -msgstr "" - msgid "" "For that, we use the `:argument-precedence-order` option when declaring a " "generic function:" @@ -168,13 +162,6 @@ msgid "" "not for class definitions makes a lot of sense." msgstr "" -msgid "" -"When declaring a class, we can choose the precedence order, and that is " -"about it. But when defining a generic function, the order of argumentws is " -"more important to the function semantics, and the argument precedence being " -"left-to-right is just the default behaviour." -msgstr "" - msgid "" "One shouldn't change the order of arguments of a generic function for the " "sake of tailoring it to the CLOS priority ranking algorithm, but doing it " @@ -183,3 +170,29 @@ msgstr "" msgid "TIL." msgstr "" + +msgid "" +"CLOS has to make a choice between the first and the second definition of " +"`yet-another-fn`, but its choice is just a heuristic. What if we want the " +"choice to be based on the second argument, instead of the first?" +msgstr "" + +msgid "" +"When declaring a class, we can choose the precedence order, and that is " +"about it. But when defining a generic function, the order of arguments is " +"more important to the function semantics, and the argument precedence being " +"left-to-right is just the default behaviour." +msgstr "" + +#~ msgid "" +#~ "CLOS has to make a choice between the first and the second definition of " +#~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" +#~ " choice to be based on the second argument first?" +#~ msgstr "" + +#~ msgid "" +#~ "When declaring a class, we can choose the precedence order, and that is " +#~ "about it. But when defining a generic function, the order of argumentws is " +#~ "more important to the function semantics, and the argument precedence being " +#~ "left-to-right is just the default behaviour." +#~ msgstr "" diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 67ff1b4..67c4f2e 100644 --- a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -96,20 +96,6 @@ msgstr "" msgid "My attempt at writing an equivalent for Common Lisp gives me:" msgstr "" -msgid "" -"(defun curry-n (n fn)\n" -" (if (= 0 n)\n" -" (funcall fn)\n" -" (lambda (&rest rest)\n" -" (curry-n (something n) fn))))\n" -"\n" -"(defun add (a b c d e)\n" -" (curry-n\n" -" (length '(a b c d e))\n" -" (lambda (&rest rest)\n" -" (apply #'+ rest))))\n" -msgstr "" - msgid "" "Without built-in multi-arity support, we have to do more work, like tracking" " the number of arguments consumed so far. That is, without dependending on " @@ -125,3 +111,31 @@ msgid "" "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " "arguments, docstrings, etc., but it also could evolve to do so." msgstr "" + +msgid "" +"(defun curry-n (n fn)\n" +" (if (= 0 n)\n" +" (funcall fn)\n" +" (lambda (&rest rest)\n" +" (curry-n (something n) fn))))\n" +"\n" +"(defun add (a b c d e)\n" +" (curry-n\n" +" (length '(a b c d e))\n" +" (lambda (&rest rest)\n" +" (apply #'+ rest))))\n" +msgstr "" + +#~ msgid "" +#~ "(defun curry-n (n fn)\n" +#~ " (if (= 0 n)\n" +#~ " (funcall fn)\n" +#~ " (lambda (&rest rest)\n" +#~ " (curry-n (something n) fn))))\n" +#~ "\n" +#~ "(defun add (a b c d e)\n" +#~ " (curry-n\n" +#~ " (length '(a b c d e))\n" +#~ " (lambda (&rest rest)\n" +#~ " (apply #'+ rest))))\n" +#~ msgstr "" diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index b773879..4ca9625 100644 --- a/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -120,12 +120,6 @@ msgid "" ":FIRST-ARG-SPECIALIZED\n" msgstr "" -msgid "" -"CLOS has to make a choice between the first and the second definition of " -"`yet-another-fn`, but its choice is just a heuristic. What if we want to the" -" choice to be based on the second argument first?" -msgstr "" - msgid "" "For that, we use the `:argument-precedence-order` option when declaring a " "generic function:" @@ -168,13 +162,6 @@ msgid "" "not for class definitions makes a lot of sense." msgstr "" -msgid "" -"When declaring a class, we can choose the precedence order, and that is " -"about it. But when defining a generic function, the order of argumentws is " -"more important to the function semantics, and the argument precedence being " -"left-to-right is just the default behaviour." -msgstr "" - msgid "" "One shouldn't change the order of arguments of a generic function for the " "sake of tailoring it to the CLOS priority ranking algorithm, but doing it " @@ -183,3 +170,29 @@ msgstr "" msgid "TIL." msgstr "" + +msgid "" +"CLOS has to make a choice between the first and the second definition of " +"`yet-another-fn`, but its choice is just a heuristic. What if we want the " +"choice to be based on the second argument, instead of the first?" +msgstr "" + +msgid "" +"When declaring a class, we can choose the precedence order, and that is " +"about it. But when defining a generic function, the order of arguments is " +"more important to the function semantics, and the argument precedence being " +"left-to-right is just the default behaviour." +msgstr "" + +#~ msgid "" +#~ "CLOS has to make a choice between the first and the second definition of " +#~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" +#~ " choice to be based on the second argument first?" +#~ msgstr "" + +#~ msgid "" +#~ "When declaring a class, we can choose the precedence order, and that is " +#~ "about it. But when defining a generic function, the order of argumentws is " +#~ "more important to the function semantics, and the argument precedence being " +#~ "left-to-right is just the default behaviour." +#~ msgstr "" diff --git a/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 67ff1b4..67c4f2e 100644 --- a/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -96,20 +96,6 @@ msgstr "" msgid "My attempt at writing an equivalent for Common Lisp gives me:" msgstr "" -msgid "" -"(defun curry-n (n fn)\n" -" (if (= 0 n)\n" -" (funcall fn)\n" -" (lambda (&rest rest)\n" -" (curry-n (something n) fn))))\n" -"\n" -"(defun add (a b c d e)\n" -" (curry-n\n" -" (length '(a b c d e))\n" -" (lambda (&rest rest)\n" -" (apply #'+ rest))))\n" -msgstr "" - msgid "" "Without built-in multi-arity support, we have to do more work, like tracking" " the number of arguments consumed so far. That is, without dependending on " @@ -125,3 +111,31 @@ msgid "" "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " "arguments, docstrings, etc., but it also could evolve to do so." msgstr "" + +msgid "" +"(defun curry-n (n fn)\n" +" (if (= 0 n)\n" +" (funcall fn)\n" +" (lambda (&rest rest)\n" +" (curry-n (something n) fn))))\n" +"\n" +"(defun add (a b c d e)\n" +" (curry-n\n" +" (length '(a b c d e))\n" +" (lambda (&rest rest)\n" +" (apply #'+ rest))))\n" +msgstr "" + +#~ msgid "" +#~ "(defun curry-n (n fn)\n" +#~ " (if (= 0 n)\n" +#~ " (funcall fn)\n" +#~ " (lambda (&rest rest)\n" +#~ " (curry-n (something n) fn))))\n" +#~ "\n" +#~ "(defun add (a b c d e)\n" +#~ " (curry-n\n" +#~ " (length '(a b c d e))\n" +#~ " (lambda (&rest rest)\n" +#~ " (apply #'+ rest))))\n" +#~ msgstr "" diff --git a/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index b773879..4ca9625 100644 --- a/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -120,12 +120,6 @@ msgid "" ":FIRST-ARG-SPECIALIZED\n" msgstr "" -msgid "" -"CLOS has to make a choice between the first and the second definition of " -"`yet-another-fn`, but its choice is just a heuristic. What if we want to the" -" choice to be based on the second argument first?" -msgstr "" - msgid "" "For that, we use the `:argument-precedence-order` option when declaring a " "generic function:" @@ -168,13 +162,6 @@ msgid "" "not for class definitions makes a lot of sense." msgstr "" -msgid "" -"When declaring a class, we can choose the precedence order, and that is " -"about it. But when defining a generic function, the order of argumentws is " -"more important to the function semantics, and the argument precedence being " -"left-to-right is just the default behaviour." -msgstr "" - msgid "" "One shouldn't change the order of arguments of a generic function for the " "sake of tailoring it to the CLOS priority ranking algorithm, but doing it " @@ -183,3 +170,29 @@ msgstr "" msgid "TIL." msgstr "" + +msgid "" +"CLOS has to make a choice between the first and the second definition of " +"`yet-another-fn`, but its choice is just a heuristic. What if we want the " +"choice to be based on the second argument, instead of the first?" +msgstr "" + +msgid "" +"When declaring a class, we can choose the precedence order, and that is " +"about it. But when defining a generic function, the order of arguments is " +"more important to the function semantics, and the argument precedence being " +"left-to-right is just the default behaviour." +msgstr "" + +#~ msgid "" +#~ "CLOS has to make a choice between the first and the second definition of " +#~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" +#~ " choice to be based on the second argument first?" +#~ msgstr "" + +#~ msgid "" +#~ "When declaring a class, we can choose the precedence order, and that is " +#~ "about it. But when defining a generic function, the order of argumentws is " +#~ "more important to the function semantics, and the argument precedence being " +#~ "left-to-right is just the default behaviour." +#~ msgstr "" -- cgit v1.2.3 From 75423d429d637a311748adff0599136c70522f12 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 24 Apr 2021 18:28:27 -0300 Subject: Add references section to TIL on CLOS --- ...browse-a-git-repository-at-a-specific-commit.md | 2 +- ...order-parameterization-of-a-generic-function.md | 4 ++ ...browse-a-git-repository-at-a-specific-commit.po | 9 ++- .../_tils/2021-04-24-clojure-auto-curry.po | 79 ++++++++++++---------- ...order-parameterization-of-a-generic-function.po | 9 +++ ...browse-a-git-repository-at-a-specific-commit.po | 9 ++- .../_tils/2021-04-24-clojure-auto-curry.po | 79 ++++++++++++---------- ...order-parameterization-of-a-generic-function.po | 9 +++ ...browse-a-git-repository-at-a-specific-commit.po | 9 ++- .../_tils/2021-04-24-clojure-auto-curry.po | 79 ++++++++++++---------- ...order-parameterization-of-a-generic-function.po | 9 +++ 11 files changed, 179 insertions(+), 118 deletions(-) (limited to 'locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po') diff --git a/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.md b/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.md index 7965d29..d06f0c1 100644 --- a/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.md +++ b/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.md @@ -77,7 +77,7 @@ After any of those checkouts, you have to `git reset .` to reset your current staging area back to what it was before the checkout. -## References: +## References 1. [GIT: Checkout to a specific folder][0] (StackOverflow) diff --git a/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.md b/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.md index eb19b38..cce0e42 100644 --- a/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.md +++ b/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.md @@ -131,3 +131,7 @@ But when defining a generic function, the order of arguments is more important t One shouldn't change the order of arguments of a generic function for the sake of tailoring it to the CLOS priority ranking algorithm, but doing it for a class definition is just fine. TIL. + +## References + +1. [Object-Oriented Programming in Common Lisp: A Programmer's Guide to CLOS](https://en.wikipedia.org/wiki/Object-Oriented_Programming_in_Common_Lisp), by Sonja E. Keene diff --git a/locale/eo/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po b/locale/eo/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po index 421e295..6030e0c 100644 --- a/locale/eo/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po +++ b/locale/eo/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po @@ -49,9 +49,6 @@ msgid "" "current staging area back to what it was before the checkout." msgstr "" -msgid "References:" -msgstr "" - msgid "" "[GIT: Checkout to a specific folder](https://stackoverflow.com/a/16493707) " "(StackOverflow)" @@ -107,6 +104,12 @@ msgstr "" msgid "eu_categories: git" msgstr "" +msgid "References" +msgstr "" + +#~ msgid "References:" +#~ msgstr "" + #~ msgid "" #~ "title: Browse a git repository at a specific commit\n" #~ "date: 2020-08-14\n" diff --git a/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 67c4f2e..8e448d0 100644 --- a/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -17,13 +17,6 @@ msgstr "" msgid "ref: clojure-auto-curry" msgstr "" -msgid "" -"A simple macro defined by [Loretta " -"He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " -"create Clojure functions that are curried on all arguments, relying on " -"Clojure's multi-arity support:" -msgstr "" - msgid "" "(defmacro defcurry\n" " [fname args & body]\n" @@ -90,41 +83,55 @@ msgstr "" msgid "Same Clojure as before, now with auto-currying via macros." msgstr "" -msgid "Comparison with Common Lisp" +msgid "" +"Here's a simple macro defined by [Loretta " +"He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " +"create Clojure functions that are curried on all arguments, relying on " +"Clojure's multi-arity support:" msgstr "" -msgid "My attempt at writing an equivalent for Common Lisp gives me:" -msgstr "" +#~ msgid "" +#~ "A simple macro defined by [Loretta " +#~ "He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " +#~ "create Clojure functions that are curried on all arguments, relying on " +#~ "Clojure's multi-arity support:" +#~ msgstr "" -msgid "" -"Without built-in multi-arity support, we have to do more work, like tracking" -" the number of arguments consumed so far. That is, without dependending on " -"any library, sticking to ANSI Common Lisp." -msgstr "" +#~ msgid "Comparison with Common Lisp" +#~ msgstr "" -msgid "" -"This also require `funcall`s, since we return a `lambda` that doesn't live " -"in the function namespace." -msgstr "" +#~ msgid "My attempt at writing an equivalent for Common Lisp gives me:" +#~ msgstr "" -msgid "" -"Like the Clojure one, it doesn't support optional parameters, `&rest` rest " -"arguments, docstrings, etc., but it also could evolve to do so." -msgstr "" +#~ msgid "" +#~ "Without built-in multi-arity support, we have to do more work, like tracking" +#~ " the number of arguments consumed so far. That is, without dependending on " +#~ "any library, sticking to ANSI Common Lisp." +#~ msgstr "" -msgid "" -"(defun curry-n (n fn)\n" -" (if (= 0 n)\n" -" (funcall fn)\n" -" (lambda (&rest rest)\n" -" (curry-n (something n) fn))))\n" -"\n" -"(defun add (a b c d e)\n" -" (curry-n\n" -" (length '(a b c d e))\n" -" (lambda (&rest rest)\n" -" (apply #'+ rest))))\n" -msgstr "" +#~ msgid "" +#~ "This also require `funcall`s, since we return a `lambda` that doesn't live " +#~ "in the function namespace." +#~ msgstr "" + +#~ msgid "" +#~ "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " +#~ "arguments, docstrings, etc., but it also could evolve to do so." +#~ msgstr "" + +#~ msgid "" +#~ "(defun curry-n (n fn)\n" +#~ " (if (= 0 n)\n" +#~ " (funcall fn)\n" +#~ " (lambda (&rest rest)\n" +#~ " (curry-n (something n) fn))))\n" +#~ "\n" +#~ "(defun add (a b c d e)\n" +#~ " (curry-n\n" +#~ " (length '(a b c d e))\n" +#~ " (lambda (&rest rest)\n" +#~ " (apply #'+ rest))))\n" +#~ msgstr "" #~ msgid "" #~ "(defun curry-n (n fn)\n" diff --git a/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index 4ca9625..2676e93 100644 --- a/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -184,6 +184,15 @@ msgid "" "left-to-right is just the default behaviour." msgstr "" +msgid "References" +msgstr "" + +msgid "" +"[Object-Oriented Programming in Common Lisp: A Programmer's Guide to " +"CLOS](https://en.wikipedia.org/wiki/Object-" +"Oriented_Programming_in_Common_Lisp), by Sonja E. Keene" +msgstr "" + #~ msgid "" #~ "CLOS has to make a choice between the first and the second definition of " #~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" diff --git a/locale/fr/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po b/locale/fr/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po index 421e295..6030e0c 100644 --- a/locale/fr/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po +++ b/locale/fr/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po @@ -49,9 +49,6 @@ msgid "" "current staging area back to what it was before the checkout." msgstr "" -msgid "References:" -msgstr "" - msgid "" "[GIT: Checkout to a specific folder](https://stackoverflow.com/a/16493707) " "(StackOverflow)" @@ -107,6 +104,12 @@ msgstr "" msgid "eu_categories: git" msgstr "" +msgid "References" +msgstr "" + +#~ msgid "References:" +#~ msgstr "" + #~ msgid "" #~ "title: Browse a git repository at a specific commit\n" #~ "date: 2020-08-14\n" diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 67c4f2e..8e448d0 100644 --- a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -17,13 +17,6 @@ msgstr "" msgid "ref: clojure-auto-curry" msgstr "" -msgid "" -"A simple macro defined by [Loretta " -"He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " -"create Clojure functions that are curried on all arguments, relying on " -"Clojure's multi-arity support:" -msgstr "" - msgid "" "(defmacro defcurry\n" " [fname args & body]\n" @@ -90,41 +83,55 @@ msgstr "" msgid "Same Clojure as before, now with auto-currying via macros." msgstr "" -msgid "Comparison with Common Lisp" +msgid "" +"Here's a simple macro defined by [Loretta " +"He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " +"create Clojure functions that are curried on all arguments, relying on " +"Clojure's multi-arity support:" msgstr "" -msgid "My attempt at writing an equivalent for Common Lisp gives me:" -msgstr "" +#~ msgid "" +#~ "A simple macro defined by [Loretta " +#~ "He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " +#~ "create Clojure functions that are curried on all arguments, relying on " +#~ "Clojure's multi-arity support:" +#~ msgstr "" -msgid "" -"Without built-in multi-arity support, we have to do more work, like tracking" -" the number of arguments consumed so far. That is, without dependending on " -"any library, sticking to ANSI Common Lisp." -msgstr "" +#~ msgid "Comparison with Common Lisp" +#~ msgstr "" -msgid "" -"This also require `funcall`s, since we return a `lambda` that doesn't live " -"in the function namespace." -msgstr "" +#~ msgid "My attempt at writing an equivalent for Common Lisp gives me:" +#~ msgstr "" -msgid "" -"Like the Clojure one, it doesn't support optional parameters, `&rest` rest " -"arguments, docstrings, etc., but it also could evolve to do so." -msgstr "" +#~ msgid "" +#~ "Without built-in multi-arity support, we have to do more work, like tracking" +#~ " the number of arguments consumed so far. That is, without dependending on " +#~ "any library, sticking to ANSI Common Lisp." +#~ msgstr "" -msgid "" -"(defun curry-n (n fn)\n" -" (if (= 0 n)\n" -" (funcall fn)\n" -" (lambda (&rest rest)\n" -" (curry-n (something n) fn))))\n" -"\n" -"(defun add (a b c d e)\n" -" (curry-n\n" -" (length '(a b c d e))\n" -" (lambda (&rest rest)\n" -" (apply #'+ rest))))\n" -msgstr "" +#~ msgid "" +#~ "This also require `funcall`s, since we return a `lambda` that doesn't live " +#~ "in the function namespace." +#~ msgstr "" + +#~ msgid "" +#~ "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " +#~ "arguments, docstrings, etc., but it also could evolve to do so." +#~ msgstr "" + +#~ msgid "" +#~ "(defun curry-n (n fn)\n" +#~ " (if (= 0 n)\n" +#~ " (funcall fn)\n" +#~ " (lambda (&rest rest)\n" +#~ " (curry-n (something n) fn))))\n" +#~ "\n" +#~ "(defun add (a b c d e)\n" +#~ " (curry-n\n" +#~ " (length '(a b c d e))\n" +#~ " (lambda (&rest rest)\n" +#~ " (apply #'+ rest))))\n" +#~ msgstr "" #~ msgid "" #~ "(defun curry-n (n fn)\n" diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index 4ca9625..2676e93 100644 --- a/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -184,6 +184,15 @@ msgid "" "left-to-right is just the default behaviour." msgstr "" +msgid "References" +msgstr "" + +msgid "" +"[Object-Oriented Programming in Common Lisp: A Programmer's Guide to " +"CLOS](https://en.wikipedia.org/wiki/Object-" +"Oriented_Programming_in_Common_Lisp), by Sonja E. Keene" +msgstr "" + #~ msgid "" #~ "CLOS has to make a choice between the first and the second definition of " #~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" diff --git a/locale/pt/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po b/locale/pt/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po index 421e295..6030e0c 100644 --- a/locale/pt/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po +++ b/locale/pt/LC_MESSAGES/_tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.po @@ -49,9 +49,6 @@ msgid "" "current staging area back to what it was before the checkout." msgstr "" -msgid "References:" -msgstr "" - msgid "" "[GIT: Checkout to a specific folder](https://stackoverflow.com/a/16493707) " "(StackOverflow)" @@ -107,6 +104,12 @@ msgstr "" msgid "eu_categories: git" msgstr "" +msgid "References" +msgstr "" + +#~ msgid "References:" +#~ msgstr "" + #~ msgid "" #~ "title: Browse a git repository at a specific commit\n" #~ "date: 2020-08-14\n" diff --git a/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 67c4f2e..8e448d0 100644 --- a/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -17,13 +17,6 @@ msgstr "" msgid "ref: clojure-auto-curry" msgstr "" -msgid "" -"A simple macro defined by [Loretta " -"He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " -"create Clojure functions that are curried on all arguments, relying on " -"Clojure's multi-arity support:" -msgstr "" - msgid "" "(defmacro defcurry\n" " [fname args & body]\n" @@ -90,41 +83,55 @@ msgstr "" msgid "Same Clojure as before, now with auto-currying via macros." msgstr "" -msgid "Comparison with Common Lisp" +msgid "" +"Here's a simple macro defined by [Loretta " +"He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " +"create Clojure functions that are curried on all arguments, relying on " +"Clojure's multi-arity support:" msgstr "" -msgid "My attempt at writing an equivalent for Common Lisp gives me:" -msgstr "" +#~ msgid "" +#~ "A simple macro defined by [Loretta " +#~ "He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " +#~ "create Clojure functions that are curried on all arguments, relying on " +#~ "Clojure's multi-arity support:" +#~ msgstr "" -msgid "" -"Without built-in multi-arity support, we have to do more work, like tracking" -" the number of arguments consumed so far. That is, without dependending on " -"any library, sticking to ANSI Common Lisp." -msgstr "" +#~ msgid "Comparison with Common Lisp" +#~ msgstr "" -msgid "" -"This also require `funcall`s, since we return a `lambda` that doesn't live " -"in the function namespace." -msgstr "" +#~ msgid "My attempt at writing an equivalent for Common Lisp gives me:" +#~ msgstr "" -msgid "" -"Like the Clojure one, it doesn't support optional parameters, `&rest` rest " -"arguments, docstrings, etc., but it also could evolve to do so." -msgstr "" +#~ msgid "" +#~ "Without built-in multi-arity support, we have to do more work, like tracking" +#~ " the number of arguments consumed so far. That is, without dependending on " +#~ "any library, sticking to ANSI Common Lisp." +#~ msgstr "" -msgid "" -"(defun curry-n (n fn)\n" -" (if (= 0 n)\n" -" (funcall fn)\n" -" (lambda (&rest rest)\n" -" (curry-n (something n) fn))))\n" -"\n" -"(defun add (a b c d e)\n" -" (curry-n\n" -" (length '(a b c d e))\n" -" (lambda (&rest rest)\n" -" (apply #'+ rest))))\n" -msgstr "" +#~ msgid "" +#~ "This also require `funcall`s, since we return a `lambda` that doesn't live " +#~ "in the function namespace." +#~ msgstr "" + +#~ msgid "" +#~ "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " +#~ "arguments, docstrings, etc., but it also could evolve to do so." +#~ msgstr "" + +#~ msgid "" +#~ "(defun curry-n (n fn)\n" +#~ " (if (= 0 n)\n" +#~ " (funcall fn)\n" +#~ " (lambda (&rest rest)\n" +#~ " (curry-n (something n) fn))))\n" +#~ "\n" +#~ "(defun add (a b c d e)\n" +#~ " (curry-n\n" +#~ " (length '(a b c d e))\n" +#~ " (lambda (&rest rest)\n" +#~ " (apply #'+ rest))))\n" +#~ msgstr "" #~ msgid "" #~ "(defun curry-n (n fn)\n" diff --git a/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index 4ca9625..2676e93 100644 --- a/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -184,6 +184,15 @@ msgid "" "left-to-right is just the default behaviour." msgstr "" +msgid "References" +msgstr "" + +msgid "" +"[Object-Oriented Programming in Common Lisp: A Programmer's Guide to " +"CLOS](https://en.wikipedia.org/wiki/Object-" +"Oriented_Programming_in_Common_Lisp), by Sonja E. Keene" +msgstr "" + #~ msgid "" #~ "CLOS has to make a choice between the first and the second definition of " #~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" -- cgit v1.2.3 From 0e6bf02503fffd89891eb37f023911ff98d022cf Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 24 Apr 2021 18:57:40 -0300 Subject: Update locale files --- .../_tils/2021-04-24-clojure-auto-curry.po | 9 ++- ...order-parameterization-of-a-generic-function.po | 9 ++- ...04-24-three-way-conditional-for-number-signs.po | 84 ++++++++++++++++++++++ .../_tils/2021-04-24-clojure-auto-curry.po | 9 ++- ...order-parameterization-of-a-generic-function.po | 9 ++- ...04-24-three-way-conditional-for-number-signs.po | 84 ++++++++++++++++++++++ .../_tils/2021-04-24-clojure-auto-curry.po | 9 ++- ...order-parameterization-of-a-generic-function.po | 9 ++- ...04-24-three-way-conditional-for-number-signs.po | 84 ++++++++++++++++++++++ 9 files changed, 288 insertions(+), 18 deletions(-) create mode 100644 locale/eo/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po create mode 100644 locale/fr/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po create mode 100644 locale/pt/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po (limited to 'locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po') diff --git a/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 8e448d0..14036ab 100644 --- a/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -5,9 +5,6 @@ msgstr "" msgid "title: Clojure auto curry" msgstr "" -msgid "date: 2021-04-24" -msgstr "" - msgid "layout: post" msgstr "" @@ -90,6 +87,12 @@ msgid "" "Clojure's multi-arity support:" msgstr "" +msgid "date: 2021-04-24 1" +msgstr "" + +#~ msgid "date: 2021-04-24" +#~ msgstr "" + #~ msgid "" #~ "A simple macro defined by [Loretta " #~ "He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " diff --git a/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index 2676e93..6aa66a8 100644 --- a/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/eo/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -7,9 +7,6 @@ msgid "" "function" msgstr "" -msgid "date: 2021-04-24" -msgstr "" - msgid "layout: post" msgstr "" @@ -193,6 +190,12 @@ msgid "" "Oriented_Programming_in_Common_Lisp), by Sonja E. Keene" msgstr "" +msgid "date: 2021-04-24 2" +msgstr "" + +#~ msgid "date: 2021-04-24" +#~ msgstr "" + #~ msgid "" #~ "CLOS has to make a choice between the first and the second definition of " #~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" diff --git a/locale/eo/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po b/locale/eo/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po new file mode 100644 index 0000000..4b98383 --- /dev/null +++ b/locale/eo/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po @@ -0,0 +1,84 @@ +# +msgid "" +msgstr "" + +msgid "title: Three-way conditional for number signs" +msgstr "" + +msgid "date: 2021-04-24 3" +msgstr "" + +msgid "layout: post" +msgstr "" + +msgid "lang: en" +msgstr "" + +msgid "ref: three-way-conditional-for-number-signs" +msgstr "" + +msgid "" +"A useful macro from Paul Graham's [On " +"Lisp](http://www.paulgraham.com/onlisptext.html) book:" +msgstr "" + +msgid "" +"(defmacro nif (expr pos zero neg)\n" +" (let ((g (gensym)))\n" +" `(let ((,g ,expr))\n" +" (cond ((plusp ,g) ,pos)\n" +" ((zerop ,g) ,zero)\n" +" (t ,neg)))))\n" +msgstr "" + +msgid "" +"After I looked at this macro, I started seeing opportunities to using it in " +"many places, and yet I didn't see anyonelse using it." +msgstr "" + +msgid "" +"The latest example I can think of is section 1.3.3 of [Structure and " +"Interpretation of Computer " +"Programs](https://mitpress.mit.edu/sites/default/files/sicp/index.html), " +"which I was reading recently:" +msgstr "" + +msgid "" +"(define (search f neg-point pos-point)\n" +" (let ((midpoint (average neg-point pos-point)))\n" +" (if (close-enough? neg-point post-point)\n" +" midpoint\n" +" (let ((test-value (f midpoint)))\n" +" (cond ((positive? test-value)\n" +" (search f neg-point midpoint))\n" +" ((negative? test-value)\n" +" (search f midpoint pos-point))\n" +" (else midpoint))))))\n" +msgstr "" + +msgid "" +"Not that the book should introduce such macro this early, but I couldn't " +"avoid feeling bothered by not using a `nif` macro, which could even remove " +"the need for the intermediate `test-value` variable:" +msgstr "" + +msgid "" +"(define (search f neg-point pos-point)\n" +" (let ((midpoint (average neg-point pos-point)))\n" +" (if (close-enough? neg-point post-point)\n" +" midpoint\n" +" (nif (f midpoint)\n" +" (search f neg-point midpoint)\n" +" (midpoint)\n" +" (search f midpoint pos-point)))))\n" +msgstr "" + +msgid "" +"It also avoids `cond`'s extra clunky parentheses for grouping, which is " +"unnecessary but built-in." +msgstr "" + +msgid "" +"As a macro, I personally feel it tilts the balance towards expressivenes " +"despite its extra cognitive load toll." +msgstr "" diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 8e448d0..14036ab 100644 --- a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -5,9 +5,6 @@ msgstr "" msgid "title: Clojure auto curry" msgstr "" -msgid "date: 2021-04-24" -msgstr "" - msgid "layout: post" msgstr "" @@ -90,6 +87,12 @@ msgid "" "Clojure's multi-arity support:" msgstr "" +msgid "date: 2021-04-24 1" +msgstr "" + +#~ msgid "date: 2021-04-24" +#~ msgstr "" + #~ msgid "" #~ "A simple macro defined by [Loretta " #~ "He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index 2676e93..6aa66a8 100644 --- a/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -7,9 +7,6 @@ msgid "" "function" msgstr "" -msgid "date: 2021-04-24" -msgstr "" - msgid "layout: post" msgstr "" @@ -193,6 +190,12 @@ msgid "" "Oriented_Programming_in_Common_Lisp), by Sonja E. Keene" msgstr "" +msgid "date: 2021-04-24 2" +msgstr "" + +#~ msgid "date: 2021-04-24" +#~ msgstr "" + #~ msgid "" #~ "CLOS has to make a choice between the first and the second definition of " #~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po new file mode 100644 index 0000000..4b98383 --- /dev/null +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po @@ -0,0 +1,84 @@ +# +msgid "" +msgstr "" + +msgid "title: Three-way conditional for number signs" +msgstr "" + +msgid "date: 2021-04-24 3" +msgstr "" + +msgid "layout: post" +msgstr "" + +msgid "lang: en" +msgstr "" + +msgid "ref: three-way-conditional-for-number-signs" +msgstr "" + +msgid "" +"A useful macro from Paul Graham's [On " +"Lisp](http://www.paulgraham.com/onlisptext.html) book:" +msgstr "" + +msgid "" +"(defmacro nif (expr pos zero neg)\n" +" (let ((g (gensym)))\n" +" `(let ((,g ,expr))\n" +" (cond ((plusp ,g) ,pos)\n" +" ((zerop ,g) ,zero)\n" +" (t ,neg)))))\n" +msgstr "" + +msgid "" +"After I looked at this macro, I started seeing opportunities to using it in " +"many places, and yet I didn't see anyonelse using it." +msgstr "" + +msgid "" +"The latest example I can think of is section 1.3.3 of [Structure and " +"Interpretation of Computer " +"Programs](https://mitpress.mit.edu/sites/default/files/sicp/index.html), " +"which I was reading recently:" +msgstr "" + +msgid "" +"(define (search f neg-point pos-point)\n" +" (let ((midpoint (average neg-point pos-point)))\n" +" (if (close-enough? neg-point post-point)\n" +" midpoint\n" +" (let ((test-value (f midpoint)))\n" +" (cond ((positive? test-value)\n" +" (search f neg-point midpoint))\n" +" ((negative? test-value)\n" +" (search f midpoint pos-point))\n" +" (else midpoint))))))\n" +msgstr "" + +msgid "" +"Not that the book should introduce such macro this early, but I couldn't " +"avoid feeling bothered by not using a `nif` macro, which could even remove " +"the need for the intermediate `test-value` variable:" +msgstr "" + +msgid "" +"(define (search f neg-point pos-point)\n" +" (let ((midpoint (average neg-point pos-point)))\n" +" (if (close-enough? neg-point post-point)\n" +" midpoint\n" +" (nif (f midpoint)\n" +" (search f neg-point midpoint)\n" +" (midpoint)\n" +" (search f midpoint pos-point)))))\n" +msgstr "" + +msgid "" +"It also avoids `cond`'s extra clunky parentheses for grouping, which is " +"unnecessary but built-in." +msgstr "" + +msgid "" +"As a macro, I personally feel it tilts the balance towards expressivenes " +"despite its extra cognitive load toll." +msgstr "" diff --git a/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 8e448d0..14036ab 100644 --- a/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -5,9 +5,6 @@ msgstr "" msgid "title: Clojure auto curry" msgstr "" -msgid "date: 2021-04-24" -msgstr "" - msgid "layout: post" msgstr "" @@ -90,6 +87,12 @@ msgid "" "Clojure's multi-arity support:" msgstr "" +msgid "date: 2021-04-24 1" +msgstr "" + +#~ msgid "date: 2021-04-24" +#~ msgstr "" + #~ msgid "" #~ "A simple macro defined by [Loretta " #~ "He](http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry) to " diff --git a/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po b/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po index 2676e93..6aa66a8 100644 --- a/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po +++ b/locale/pt/LC_MESSAGES/_tils/2021-04-24-common-lisp-argument-precedence-order-parameterization-of-a-generic-function.po @@ -7,9 +7,6 @@ msgid "" "function" msgstr "" -msgid "date: 2021-04-24" -msgstr "" - msgid "layout: post" msgstr "" @@ -193,6 +190,12 @@ msgid "" "Oriented_Programming_in_Common_Lisp), by Sonja E. Keene" msgstr "" +msgid "date: 2021-04-24 2" +msgstr "" + +#~ msgid "date: 2021-04-24" +#~ msgstr "" + #~ msgid "" #~ "CLOS has to make a choice between the first and the second definition of " #~ "`yet-another-fn`, but its choice is just a heuristic. What if we want to the" diff --git a/locale/pt/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po b/locale/pt/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po new file mode 100644 index 0000000..4b98383 --- /dev/null +++ b/locale/pt/LC_MESSAGES/_tils/2021-04-24-three-way-conditional-for-number-signs.po @@ -0,0 +1,84 @@ +# +msgid "" +msgstr "" + +msgid "title: Three-way conditional for number signs" +msgstr "" + +msgid "date: 2021-04-24 3" +msgstr "" + +msgid "layout: post" +msgstr "" + +msgid "lang: en" +msgstr "" + +msgid "ref: three-way-conditional-for-number-signs" +msgstr "" + +msgid "" +"A useful macro from Paul Graham's [On " +"Lisp](http://www.paulgraham.com/onlisptext.html) book:" +msgstr "" + +msgid "" +"(defmacro nif (expr pos zero neg)\n" +" (let ((g (gensym)))\n" +" `(let ((,g ,expr))\n" +" (cond ((plusp ,g) ,pos)\n" +" ((zerop ,g) ,zero)\n" +" (t ,neg)))))\n" +msgstr "" + +msgid "" +"After I looked at this macro, I started seeing opportunities to using it in " +"many places, and yet I didn't see anyonelse using it." +msgstr "" + +msgid "" +"The latest example I can think of is section 1.3.3 of [Structure and " +"Interpretation of Computer " +"Programs](https://mitpress.mit.edu/sites/default/files/sicp/index.html), " +"which I was reading recently:" +msgstr "" + +msgid "" +"(define (search f neg-point pos-point)\n" +" (let ((midpoint (average neg-point pos-point)))\n" +" (if (close-enough? neg-point post-point)\n" +" midpoint\n" +" (let ((test-value (f midpoint)))\n" +" (cond ((positive? test-value)\n" +" (search f neg-point midpoint))\n" +" ((negative? test-value)\n" +" (search f midpoint pos-point))\n" +" (else midpoint))))))\n" +msgstr "" + +msgid "" +"Not that the book should introduce such macro this early, but I couldn't " +"avoid feeling bothered by not using a `nif` macro, which could even remove " +"the need for the intermediate `test-value` variable:" +msgstr "" + +msgid "" +"(define (search f neg-point pos-point)\n" +" (let ((midpoint (average neg-point pos-point)))\n" +" (if (close-enough? neg-point post-point)\n" +" midpoint\n" +" (nif (f midpoint)\n" +" (search f neg-point midpoint)\n" +" (midpoint)\n" +" (search f midpoint pos-point)))))\n" +msgstr "" + +msgid "" +"It also avoids `cond`'s extra clunky parentheses for grouping, which is " +"unnecessary but built-in." +msgstr "" + +msgid "" +"As a macro, I personally feel it tilts the balance towards expressivenes " +"despite its extra cognitive load toll." +msgstr "" -- cgit v1.2.3 From c86b5f9555d284c254d85c4f4eacb2560d9adfd1 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Tue, 27 Apr 2021 04:45:16 -0300 Subject: Expand TIL on Clojure auto-curry to include Common Lisp version --- _tils/2021-04-24-clojure-auto-curry.md | 67 ++++++++++- .../_tils/2021-04-24-clojure-auto-curry.po | 123 ++++++++++++++++----- .../_tils/2021-04-24-clojure-auto-curry.po | 123 ++++++++++++++++----- .../_tils/2021-04-24-clojure-auto-curry.po | 123 ++++++++++++++++----- 4 files changed, 352 insertions(+), 84 deletions(-) (limited to 'locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po') diff --git a/_tils/2021-04-24-clojure-auto-curry.md b/_tils/2021-04-24-clojure-auto-curry.md index 0d50cfa..c1e277f 100644 --- a/_tils/2021-04-24-clojure-auto-curry.md +++ b/_tils/2021-04-24-clojure-auto-curry.md @@ -4,6 +4,8 @@ title: Clojure auto curry date: 2021-04-24 1 +updated_at: 2021-04-27 + layout: post lang: en @@ -16,11 +18,11 @@ Here's a simple macro defined by [Loretta He][lorettahe] to create Clojure funct ```clojure (defmacro defcurry - [fname args & body] + [name args & body] (let [partials (map (fn [n] - `(~(subvec args 0 n) (partial ~fname ~@(take n args)))) + `(~(subvec args 0 n) (partial ~name ~@(take n args)))) (range 1 (count args)))] - `(defn ~fname + `(defn ~name (~args ~@body) ~@partials))) ``` @@ -72,3 +74,62 @@ Simple and elegant. Same Clojure as before, now with auto-currying via macros. [lorettahe]: http://lorettahe.github.io/clojure/2016/09/22/clojure-auto-curry + +## Comparison with Common Lisp + +My attempt at writing an equivalent for Common Lisp gives me: + +```lisp +(defun partial (fn &rest args) + (lambda (&rest args2) + (apply fn (append args args2)))) + +(defun curry-n (n func) + (cond ((< n 0) (error "Too many arguments")) + ((zerop n) (funcall func)) + (t (lambda (&rest rest) + (curry-n (- n (length rest)) + (apply #'partial func rest)))))) + +(defmacro defcurry (name args &body body) + `(defun ,name (&rest rest) + (let ((func (lambda ,args ,@body))) + (curry-n (- ,(length args) (length rest)) + (apply #'partial func rest))))) +``` + +Without built-in multi-arity support, we have to do more work, like tracking the number of arguments consumed so far. +We also have to write `#'partial` ourselves. +That is, without dependending on any library, sticking to ANSI Common Lisp. + +The usage is pretty similar: + +```lisp +* (defcurry add (a b c d e) + (+ a b c d e)) +ADD + +* (add 1) +# + +* (funcall (add 1) 2 3 4) +# + +* (funcall (add 1) 2 3 4 5) +15 + +* (funcall (funcall (add 1) 2 3) 4 5) +15 + +* (macroexpand-1 + '(defcurry add (a b c d e) + (+ a b c d e))) +(DEFUN ADD (&REST REST) + (LET ((FUNC (LAMBDA (A B C D E) (+ A B C D E)))) + (CURRY-N (- 5 (LENGTH REST)) (APPLY #'PARTIAL FUNC REST)))) +T +``` + +This also require `funcall`s, since we return a `lambda` that doesn't live in the function namespace. + +Like the Clojure one, it doesn't support optional parameters, `&rest` rest arguments, docstrings, etc., but it also could evolve to do so. diff --git a/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 14036ab..ab59a4f 100644 --- a/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/eo/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -14,17 +14,6 @@ msgstr "" msgid "ref: clojure-auto-curry" msgstr "" -msgid "" -"(defmacro defcurry\n" -" [fname args & body]\n" -" (let [partials (map (fn [n]\n" -" `(~(subvec args 0 n) (partial ~fname ~@(take n args))))\n" -" (range 1 (count args)))]\n" -" `(defn ~fname\n" -" (~args ~@body)\n" -" ~@partials)))\n" -msgstr "" - msgid "A naive `add` definition, alongside its usage and macroexpansion:" msgstr "" @@ -90,6 +79,102 @@ msgstr "" msgid "date: 2021-04-24 1" msgstr "" +msgid "" +"(defmacro defcurry\n" +" [name args & body]\n" +" (let [partials (map (fn [n]\n" +" `(~(subvec args 0 n) (partial ~name ~@(take n args))))\n" +" (range 1 (count args)))]\n" +" `(defn ~name\n" +" (~args ~@body)\n" +" ~@partials)))\n" +msgstr "" + +msgid "Comparison with Common Lisp" +msgstr "" + +msgid "My attempt at writing an equivalent for Common Lisp gives me:" +msgstr "" + +msgid "" +"(defun partial (fn &rest args)\n" +" (lambda (&rest args2)\n" +" (apply fn (append args args2))))\n" +"\n" +"(defun curry-n (n func)\n" +" (cond ((< n 0) (error \"Too many arguments\"))\n" +" ((zerop n) (funcall func))\n" +" (t (lambda (&rest rest)\n" +" (curry-n (- n (length rest))\n" +" (apply #'partial func rest))))))\n" +"\n" +"(defmacro defcurry (name args &body body)\n" +" `(defun ,name (&rest rest)\n" +" (let ((func (lambda ,args ,@body)))\n" +" (curry-n (- ,(length args) (length rest))\n" +" (apply #'partial func rest)))))\n" +msgstr "" + +msgid "" +"Without built-in multi-arity support, we have to do more work, like tracking" +" the number of arguments consumed so far. We also have to write `#'partial` " +"ourselves. That is, without dependending on any library, sticking to ANSI " +"Common Lisp." +msgstr "" + +msgid "The usage is pretty similar:" +msgstr "" + +msgid "" +"* (defcurry add (a b c d e)\n" +" (+ a b c d e))\n" +"ADD\n" +"\n" +"* (add 1)\n" +"#\n" +"\n" +"* (funcall (add 1) 2 3 4)\n" +"#\n" +"\n" +"* (funcall (add 1) 2 3 4 5)\n" +"15\n" +"\n" +"* (funcall (funcall (add 1) 2 3) 4 5)\n" +"15\n" +"\n" +"* (macroexpand-1\n" +" '(defcurry add (a b c d e)\n" +" (+ a b c d e)))\n" +"(DEFUN ADD (&REST REST)\n" +" (LET ((FUNC (LAMBDA (A B C D E) (+ A B C D E))))\n" +" (CURRY-N (- 5 (LENGTH REST)) (APPLY #'PARTIAL FUNC REST))))\n" +"T\n" +msgstr "" + +msgid "" +"This also require `funcall`s, since we return a `lambda` that doesn't live " +"in the function namespace." +msgstr "" + +msgid "" +"Like the Clojure one, it doesn't support optional parameters, `&rest` rest " +"arguments, docstrings, etc., but it also could evolve to do so." +msgstr "" + +msgid "updated_at: 2021-04-27" +msgstr "" + +#~ msgid "" +#~ "(defmacro defcurry\n" +#~ " [fname args & body]\n" +#~ " (let [partials (map (fn [n]\n" +#~ " `(~(subvec args 0 n) (partial ~fname ~@(take n args))))\n" +#~ " (range 1 (count args)))]\n" +#~ " `(defn ~fname\n" +#~ " (~args ~@body)\n" +#~ " ~@partials)))\n" +#~ msgstr "" + #~ msgid "date: 2021-04-24" #~ msgstr "" @@ -100,28 +185,12 @@ msgstr "" #~ "Clojure's multi-arity support:" #~ msgstr "" -#~ msgid "Comparison with Common Lisp" -#~ msgstr "" - -#~ msgid "My attempt at writing an equivalent for Common Lisp gives me:" -#~ msgstr "" - #~ msgid "" #~ "Without built-in multi-arity support, we have to do more work, like tracking" #~ " the number of arguments consumed so far. That is, without dependending on " #~ "any library, sticking to ANSI Common Lisp." #~ msgstr "" -#~ msgid "" -#~ "This also require `funcall`s, since we return a `lambda` that doesn't live " -#~ "in the function namespace." -#~ msgstr "" - -#~ msgid "" -#~ "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " -#~ "arguments, docstrings, etc., but it also could evolve to do so." -#~ msgstr "" - #~ msgid "" #~ "(defun curry-n (n fn)\n" #~ " (if (= 0 n)\n" diff --git a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 14036ab..ab59a4f 100644 --- a/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/fr/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -14,17 +14,6 @@ msgstr "" msgid "ref: clojure-auto-curry" msgstr "" -msgid "" -"(defmacro defcurry\n" -" [fname args & body]\n" -" (let [partials (map (fn [n]\n" -" `(~(subvec args 0 n) (partial ~fname ~@(take n args))))\n" -" (range 1 (count args)))]\n" -" `(defn ~fname\n" -" (~args ~@body)\n" -" ~@partials)))\n" -msgstr "" - msgid "A naive `add` definition, alongside its usage and macroexpansion:" msgstr "" @@ -90,6 +79,102 @@ msgstr "" msgid "date: 2021-04-24 1" msgstr "" +msgid "" +"(defmacro defcurry\n" +" [name args & body]\n" +" (let [partials (map (fn [n]\n" +" `(~(subvec args 0 n) (partial ~name ~@(take n args))))\n" +" (range 1 (count args)))]\n" +" `(defn ~name\n" +" (~args ~@body)\n" +" ~@partials)))\n" +msgstr "" + +msgid "Comparison with Common Lisp" +msgstr "" + +msgid "My attempt at writing an equivalent for Common Lisp gives me:" +msgstr "" + +msgid "" +"(defun partial (fn &rest args)\n" +" (lambda (&rest args2)\n" +" (apply fn (append args args2))))\n" +"\n" +"(defun curry-n (n func)\n" +" (cond ((< n 0) (error \"Too many arguments\"))\n" +" ((zerop n) (funcall func))\n" +" (t (lambda (&rest rest)\n" +" (curry-n (- n (length rest))\n" +" (apply #'partial func rest))))))\n" +"\n" +"(defmacro defcurry (name args &body body)\n" +" `(defun ,name (&rest rest)\n" +" (let ((func (lambda ,args ,@body)))\n" +" (curry-n (- ,(length args) (length rest))\n" +" (apply #'partial func rest)))))\n" +msgstr "" + +msgid "" +"Without built-in multi-arity support, we have to do more work, like tracking" +" the number of arguments consumed so far. We also have to write `#'partial` " +"ourselves. That is, without dependending on any library, sticking to ANSI " +"Common Lisp." +msgstr "" + +msgid "The usage is pretty similar:" +msgstr "" + +msgid "" +"* (defcurry add (a b c d e)\n" +" (+ a b c d e))\n" +"ADD\n" +"\n" +"* (add 1)\n" +"#\n" +"\n" +"* (funcall (add 1) 2 3 4)\n" +"#\n" +"\n" +"* (funcall (add 1) 2 3 4 5)\n" +"15\n" +"\n" +"* (funcall (funcall (add 1) 2 3) 4 5)\n" +"15\n" +"\n" +"* (macroexpand-1\n" +" '(defcurry add (a b c d e)\n" +" (+ a b c d e)))\n" +"(DEFUN ADD (&REST REST)\n" +" (LET ((FUNC (LAMBDA (A B C D E) (+ A B C D E))))\n" +" (CURRY-N (- 5 (LENGTH REST)) (APPLY #'PARTIAL FUNC REST))))\n" +"T\n" +msgstr "" + +msgid "" +"This also require `funcall`s, since we return a `lambda` that doesn't live " +"in the function namespace." +msgstr "" + +msgid "" +"Like the Clojure one, it doesn't support optional parameters, `&rest` rest " +"arguments, docstrings, etc., but it also could evolve to do so." +msgstr "" + +msgid "updated_at: 2021-04-27" +msgstr "" + +#~ msgid "" +#~ "(defmacro defcurry\n" +#~ " [fname args & body]\n" +#~ " (let [partials (map (fn [n]\n" +#~ " `(~(subvec args 0 n) (partial ~fname ~@(take n args))))\n" +#~ " (range 1 (count args)))]\n" +#~ " `(defn ~fname\n" +#~ " (~args ~@body)\n" +#~ " ~@partials)))\n" +#~ msgstr "" + #~ msgid "date: 2021-04-24" #~ msgstr "" @@ -100,28 +185,12 @@ msgstr "" #~ "Clojure's multi-arity support:" #~ msgstr "" -#~ msgid "Comparison with Common Lisp" -#~ msgstr "" - -#~ msgid "My attempt at writing an equivalent for Common Lisp gives me:" -#~ msgstr "" - #~ msgid "" #~ "Without built-in multi-arity support, we have to do more work, like tracking" #~ " the number of arguments consumed so far. That is, without dependending on " #~ "any library, sticking to ANSI Common Lisp." #~ msgstr "" -#~ msgid "" -#~ "This also require `funcall`s, since we return a `lambda` that doesn't live " -#~ "in the function namespace." -#~ msgstr "" - -#~ msgid "" -#~ "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " -#~ "arguments, docstrings, etc., but it also could evolve to do so." -#~ msgstr "" - #~ msgid "" #~ "(defun curry-n (n fn)\n" #~ " (if (= 0 n)\n" diff --git a/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po b/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po index 14036ab..ab59a4f 100644 --- a/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po +++ b/locale/pt/LC_MESSAGES/_tils/2021-04-24-clojure-auto-curry.po @@ -14,17 +14,6 @@ msgstr "" msgid "ref: clojure-auto-curry" msgstr "" -msgid "" -"(defmacro defcurry\n" -" [fname args & body]\n" -" (let [partials (map (fn [n]\n" -" `(~(subvec args 0 n) (partial ~fname ~@(take n args))))\n" -" (range 1 (count args)))]\n" -" `(defn ~fname\n" -" (~args ~@body)\n" -" ~@partials)))\n" -msgstr "" - msgid "A naive `add` definition, alongside its usage and macroexpansion:" msgstr "" @@ -90,6 +79,102 @@ msgstr "" msgid "date: 2021-04-24 1" msgstr "" +msgid "" +"(defmacro defcurry\n" +" [name args & body]\n" +" (let [partials (map (fn [n]\n" +" `(~(subvec args 0 n) (partial ~name ~@(take n args))))\n" +" (range 1 (count args)))]\n" +" `(defn ~name\n" +" (~args ~@body)\n" +" ~@partials)))\n" +msgstr "" + +msgid "Comparison with Common Lisp" +msgstr "" + +msgid "My attempt at writing an equivalent for Common Lisp gives me:" +msgstr "" + +msgid "" +"(defun partial (fn &rest args)\n" +" (lambda (&rest args2)\n" +" (apply fn (append args args2))))\n" +"\n" +"(defun curry-n (n func)\n" +" (cond ((< n 0) (error \"Too many arguments\"))\n" +" ((zerop n) (funcall func))\n" +" (t (lambda (&rest rest)\n" +" (curry-n (- n (length rest))\n" +" (apply #'partial func rest))))))\n" +"\n" +"(defmacro defcurry (name args &body body)\n" +" `(defun ,name (&rest rest)\n" +" (let ((func (lambda ,args ,@body)))\n" +" (curry-n (- ,(length args) (length rest))\n" +" (apply #'partial func rest)))))\n" +msgstr "" + +msgid "" +"Without built-in multi-arity support, we have to do more work, like tracking" +" the number of arguments consumed so far. We also have to write `#'partial` " +"ourselves. That is, without dependending on any library, sticking to ANSI " +"Common Lisp." +msgstr "" + +msgid "The usage is pretty similar:" +msgstr "" + +msgid "" +"* (defcurry add (a b c d e)\n" +" (+ a b c d e))\n" +"ADD\n" +"\n" +"* (add 1)\n" +"#\n" +"\n" +"* (funcall (add 1) 2 3 4)\n" +"#\n" +"\n" +"* (funcall (add 1) 2 3 4 5)\n" +"15\n" +"\n" +"* (funcall (funcall (add 1) 2 3) 4 5)\n" +"15\n" +"\n" +"* (macroexpand-1\n" +" '(defcurry add (a b c d e)\n" +" (+ a b c d e)))\n" +"(DEFUN ADD (&REST REST)\n" +" (LET ((FUNC (LAMBDA (A B C D E) (+ A B C D E))))\n" +" (CURRY-N (- 5 (LENGTH REST)) (APPLY #'PARTIAL FUNC REST))))\n" +"T\n" +msgstr "" + +msgid "" +"This also require `funcall`s, since we return a `lambda` that doesn't live " +"in the function namespace." +msgstr "" + +msgid "" +"Like the Clojure one, it doesn't support optional parameters, `&rest` rest " +"arguments, docstrings, etc., but it also could evolve to do so." +msgstr "" + +msgid "updated_at: 2021-04-27" +msgstr "" + +#~ msgid "" +#~ "(defmacro defcurry\n" +#~ " [fname args & body]\n" +#~ " (let [partials (map (fn [n]\n" +#~ " `(~(subvec args 0 n) (partial ~fname ~@(take n args))))\n" +#~ " (range 1 (count args)))]\n" +#~ " `(defn ~fname\n" +#~ " (~args ~@body)\n" +#~ " ~@partials)))\n" +#~ msgstr "" + #~ msgid "date: 2021-04-24" #~ msgstr "" @@ -100,28 +185,12 @@ msgstr "" #~ "Clojure's multi-arity support:" #~ msgstr "" -#~ msgid "Comparison with Common Lisp" -#~ msgstr "" - -#~ msgid "My attempt at writing an equivalent for Common Lisp gives me:" -#~ msgstr "" - #~ msgid "" #~ "Without built-in multi-arity support, we have to do more work, like tracking" #~ " the number of arguments consumed so far. That is, without dependending on " #~ "any library, sticking to ANSI Common Lisp." #~ msgstr "" -#~ msgid "" -#~ "This also require `funcall`s, since we return a `lambda` that doesn't live " -#~ "in the function namespace." -#~ msgstr "" - -#~ msgid "" -#~ "Like the Clojure one, it doesn't support optional parameters, `&rest` rest " -#~ "arguments, docstrings, etc., but it also could evolve to do so." -#~ msgstr "" - #~ msgid "" #~ "(defun curry-n (n fn)\n" #~ " (if (= 0 n)\n" -- cgit v1.2.3