diff options
author | EuAndreh <eu@euandre.org> | 2023-04-04 08:33:41 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-04-04 08:43:15 -0300 |
commit | 08588f9907299b1a927e281d5c65b46b7cefa427 (patch) | |
tree | 860f8550c2efee35df9bfa1ef56e338f8331c2d1 /v2/src/content | |
parent | dynamic.mk: Use serve(1) as is (diff) | |
download | euandre.org-08588f9907299b1a927e281d5c65b46b7cefa427.tar.gz euandre.org-08588f9907299b1a927e281d5c65b46b7cefa427.tar.xz |
Revamp v2/
Diffstat (limited to 'v2/src/content')
-rw-r--r-- | v2/src/content/.well-known/security.txt | 4 | ||||
l--------- | v2/src/content/favicon.svg | 1 | ||||
-rw-r--r-- | v2/src/content/pastebins/raku-tuple-type-annotation.md | 37 | ||||
-rw-r--r-- | v2/src/content/pastebins/sicp-exercise-3-19.md | 10 | ||||
-rw-r--r-- | v2/src/content/public.asc.txt | 86 | ||||
l--------- | v2/src/content/static/atom.svg | 1 | ||||
l--------- | v2/src/content/static/envelope.svg | 1 | ||||
l--------- | v2/src/content/static/favicon.svg | 1 | ||||
l--------- | v2/src/content/static/link.svg | 1 | ||||
l--------- | v2/src/content/static/lock.svg | 1 | ||||
l--------- | v2/src/content/static/public.asc.txt | 1 | ||||
-rw-r--r-- | v2/src/content/style.css (renamed from v2/src/content/static/styles.css) | 0 | ||||
-rw-r--r-- | v2/src/content/tils/lisp-three-way-conditional.md | 63 |
13 files changed, 196 insertions, 11 deletions
diff --git a/v2/src/content/.well-known/security.txt b/v2/src/content/.well-known/security.txt new file mode 100644 index 0000000..dd35c49 --- /dev/null +++ b/v2/src/content/.well-known/security.txt @@ -0,0 +1,4 @@ +Contact: mailto:eu@euandre.org +Encryption: https://euandre.org/public.asc.txt +Expires: 2024-07-15T00:00:00z +Preferred-Languages: en, pt diff --git a/v2/src/content/favicon.svg b/v2/src/content/favicon.svg new file mode 120000 index 0000000..313dcc5 --- /dev/null +++ b/v2/src/content/favicon.svg @@ -0,0 +1 @@ +../../../static/lord-favicon.svg
\ No newline at end of file diff --git a/v2/src/content/pastebins/raku-tuple-type-annotation.md b/v2/src/content/pastebins/raku-tuple-type-annotation.md new file mode 100644 index 0000000..3d5ff34 --- /dev/null +++ b/v2/src/content/pastebins/raku-tuple-type-annotation.md @@ -0,0 +1,37 @@ +--- + +title: Raku tuple type annotation + +date: 2019-12-29 + +layout: post + +lang: en + +ref: raku-tuple-type-annotation + +--- + +```perl +# Single Str return value: this works +sub f1(Str $in --> Str) { + $in; +} + +# Tuple of Str as return value: this works +sub f2(Str $in) { + ($in, $in); +} + +# Tuple of Str as return value with type annotation: this doesn't works +sub f2(Str $in --> (Str, Str)) { + ($in, $in); +} +``` + +Error log is: + +```perl +===SORRY!=== Error while compiling /path/to/my/file +Malformed return value +``` diff --git a/v2/src/content/pastebins/sicp-exercise-3-19.md b/v2/src/content/pastebins/sicp-exercise-3-19.md index fd2c52b..8834889 100644 --- a/v2/src/content/pastebins/sicp-exercise-3-19.md +++ b/v2/src/content/pastebins/sicp-exercise-3-19.md @@ -1,14 +1,14 @@ --- -TITLE='SICP exercise 3.19' +title: SICP exercise 3.19 -DATE='2021-09-02' +date: 2021-09-02 -LAYOUT='post' +layout: post -LANGUAGE='en' +lang: en -REF='sicp-exercise-3-19' +id: sicp-exercise-3-19 --- diff --git a/v2/src/content/public.asc.txt b/v2/src/content/public.asc.txt new file mode 100644 index 0000000..533b54c --- /dev/null +++ b/v2/src/content/public.asc.txt @@ -0,0 +1,86 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBFjVvh4BEADIlHUiO6IfkhcNm3J7ilXERgimvKuFNyLIUPZlDcESC1ORrv4y +9slMDA5uojXctuLRC7nNdynLP+eFFfVUQ+hUXcV24AzyOE0CYo5c4PQA5TLe2AUC +E9YqqfQF4XuNddY+UpcG47MuVDR+6SHkFkF29ATzpmShJj41lc7a9CdRib+62Wpe +h7WJOFj/YoxMCBBzic4tiFNgoYobu+lLxyA4T2kCmxEaiZz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WzlgfkOw801 +YGAFAmC7n68CGyAFCQPCZwAACgkQgfkOw801YGAS7hAAvAEKKdNj8NK8STfehHIH +QYxdotNHJc3b0rUa/Kzb9ELTvYgheHH6Dq26c/YSoApJxUrgUVDSJwAJV4T9JqPX +rfCfhyzfdxocXVAWH01dhWWxCOh/S/gLB/r2CvymbFbNGY6y8vyxG8TahGYZQJEE +ynUtw+S1sfrbqc8EMGmnw67z/hK3JIcfNrNxvt7FXo1HHcNEMRiah2NtwO9sumEK +041y7v2efGS4z1i5FIarf/2HtIgIGs77B0G54o4IhgzJzUEYWlHumXKMsETNT3zI +9uukR16RRkwxqOj6fOD9qNvnM1Tzf9T5DClrS5klz448qlpWWiUDABmyBMDqGKWS +vr6oi24iemJ4LoAUws1tPCE5WukFKr69UQ9Ab4DuSWwPbQ51RUjMJPeqdV53GnjU +H6gNBKqxlC0ccuwY3V2kDb8lc46pyN7rqLVZ0IENZ0PFHmfvH+rPkybEjRBqFbhf +nkDPnHuXSPhsCGPk45OQxnqqCf4QFqyOTG3slc6yk/N4Bz0IVNOFq5sewISGeolb +4uOF951f5gA2cUy5FXu8Hf8vkdJuB70nHtJLNijloPbAQFq9SuVpvAOlSFLB2wiy +VgSGXzb4jfIEJidZlsveHDkg/LTzrkHu+f1Qj5thHXN7ARPWvZp1eNFSA6iV7Sho +LsPdAc9FGcUNEy+/AlLpM1Y= +=2ZCp +-----END PGP PUBLIC KEY BLOCK----- diff --git a/v2/src/content/static/atom.svg b/v2/src/content/static/atom.svg deleted file mode 120000 index 41c6d3f..0000000 --- a/v2/src/content/static/atom.svg +++ /dev/null @@ -1 +0,0 @@ -../../../../static/atom.svg
\ No newline at end of file diff --git a/v2/src/content/static/envelope.svg b/v2/src/content/static/envelope.svg deleted file mode 120000 index bd0c577..0000000 --- a/v2/src/content/static/envelope.svg +++ /dev/null @@ -1 +0,0 @@ -../../../../static/envelope.svg
\ No newline at end of file diff --git a/v2/src/content/static/favicon.svg b/v2/src/content/static/favicon.svg deleted file mode 120000 index 33566ab..0000000 --- a/v2/src/content/static/favicon.svg +++ /dev/null @@ -1 +0,0 @@ -../../../../static/lord-favicon.svg
\ No newline at end of file diff --git a/v2/src/content/static/link.svg b/v2/src/content/static/link.svg deleted file mode 120000 index bf69c40..0000000 --- a/v2/src/content/static/link.svg +++ /dev/null @@ -1 +0,0 @@ -../../../../static/link.svg
\ No newline at end of file diff --git a/v2/src/content/static/lock.svg b/v2/src/content/static/lock.svg deleted file mode 120000 index f9a4f33..0000000 --- a/v2/src/content/static/lock.svg +++ /dev/null @@ -1 +0,0 @@ -../../../../static/lock.svg
\ No newline at end of file diff --git a/v2/src/content/static/public.asc.txt b/v2/src/content/static/public.asc.txt deleted file mode 120000 index 5175f38..0000000 --- a/v2/src/content/static/public.asc.txt +++ /dev/null @@ -1 +0,0 @@ -../../../../public.asc
\ No newline at end of file diff --git a/v2/src/content/static/styles.css b/v2/src/content/style.css index 0ec67a8..0ec67a8 100644 --- a/v2/src/content/static/styles.css +++ b/v2/src/content/style.css diff --git a/v2/src/content/tils/lisp-three-way-conditional.md b/v2/src/content/tils/lisp-three-way-conditional.md new file mode 100644 index 0000000..f53451b --- /dev/null +++ b/v2/src/content/tils/lisp-three-way-conditional.md @@ -0,0 +1,63 @@ +--- + +title: Three-way conditional for number signs on Lisp + +date: 2021-04-24 3 + +updated_at: 2021-08-14 + +layout: post + +lang: en + +ref: three-way-conditional-for-number-signs-on-lisp + +--- + +A useful macro from Paul Graham's [On Lisp][on-lisp] book: + +```lisp +(defmacro nif (expr pos zero neg) + (let ((g (gensym))) + `(let ((,g ,expr)) + (cond ((plusp ,g) ,pos) + ((zerop ,g) ,zero) + (t ,neg))))) +``` + +After I looked at this macro, I started seeing opportunities to using it in many places, and yet I didn't see anyone else using it. + +The latest example I can think of is section 1.3.3 of [Structure and Interpretation of Computer Programs][sicp], which I was reading recently: + +```scheme +(define (search f neg-point pos-point) + (let ((midpoint (average neg-point pos-point))) + (if (close-enough? neg-point post-point) + midpoint + (let ((test-value (f midpoint))) + (cond ((positive? test-value) + (search f neg-point midpoint)) + ((negative? test-value) + (search f midpoint pos-point)) + (else midpoint)))))) +``` + +Not that the book should introduce such macro this early, but I couldn't avoid feeling bothered by not using the `nif` macro, which could even remove the need for the intermediate `test-value` variable: + +```scheme +(define (search f neg-point pos-point) + (let ((midpoint (average neg-point pos-point))) + (if (close-enough? neg-point post-point) + midpoint + (nif (f midpoint) + (search f neg-point midpoint) + (midpoint) + (search f midpoint pos-point))))) +``` + +It also avoids `cond`'s extra clunky parentheses for grouping, which is unnecessary but built-in. + +As a macro, I personally feel it tilts the balance towards expressivenes despite its extra cognitive load toll. + +[on-lisp]: http://www.paulgraham.com/onlisptext.html +[sicp]: https://mitpress.mit.edu/sites/default/files/sicp/index.html |