From f3dc81930ebbc6727f9a796f71dceffbcb753752 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 16 Feb 2024 16:46:45 +0100 Subject: Added strong Rosenberg encoding for meta encoding Originally got the idea from @sgoguen (YC) and was further inspired by @hbr from one of their blog posts[1]. The current encoding has some holes and bad performance, so I might switch to a different one in the future. The wiki and metaprogramming blog post have been updated accordingly. [1] https://hbr.github.io/Lambda-Calculus/computability/text.html --- docs/wiki_src/coding/meta-programming.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'docs/wiki_src/coding/meta-programming.md') diff --git a/docs/wiki_src/coding/meta-programming.md b/docs/wiki_src/coding/meta-programming.md index 334e285..716cc7a 100644 --- a/docs/wiki_src/coding/meta-programming.md +++ b/docs/wiki_src/coding/meta-programming.md @@ -74,4 +74,12 @@ Examples: :test (map inc `0) (`1) :test (map (map inc) `[0]) (`[1]) :test (map swap `[0 1]) (`[1 0]) + +# encoding terms as numbers +:test ((encode `(0 0)) =? (+3)) (true) +:test ((encode `[0]) =? (+8)) (true) + +# decoding numbers to terms +:test (decode (+3)) (`(0 0)) +:test (decode (+8)) (`[0]) ``` -- cgit v1.2.3