{"id":2580,"date":"2021-10-17T17:54:33","date_gmt":"2021-10-17T12:24:33","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=2580"},"modified":"2021-10-17T17:54:33","modified_gmt":"2021-10-17T12:24:33","slug":"some-interesting-features-of-newlisp","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2021\/10\/17\/some-interesting-features-of-newlisp\/","title":{"rendered":"Some Interesting Features of &#8220;newLisp&#8221;"},"content":{"rendered":"<p><a href=\"http:\/\/www.newlisp.org\" target=\"_blank\" rel=\"noopener\"><em><strong>newLisp <\/strong><\/em><\/a>is a general-purpose scripting language with a <em><strong>Lisp<\/strong><\/em>-like syntax. That is one of the reasons I wanted to take a closer look at the language. It has a compact footprint, small resource requirements, and can easily be embedded. It is available on multiple platforms, and on my Windows machine, the installation has just two files: <em><strong>newlisp.exe<\/strong> <\/em>and <em><strong>newlisp.dll<\/strong><\/em><\/p>\n<p><em><strong>newLisp<\/strong><\/em> boasts of many interesting features, and I hope to explore them gradually. In today&#8217;s article, let me touch upon two of them.<\/p>\n<h3>Random Expression Evaluation<\/h3>\n<p>The function <em><strong>&#8220;amb&#8221;<\/strong><\/em> takes one or more arguments, selects one of the arguments at random, evaluates it, and returns that as its result\/value.<\/p>\n<figure id=\"attachment_2581\" aria-describedby=\"caption-attachment-2581\" style=\"width: 350px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example1.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"2581\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/10\/17\/some-interesting-features-of-newlisp\/example1-24\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example1.jpg\" data-orig-size=\"255,296\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1634460259&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"&amp;#8220;amb&amp;#8221; Function\" data-image-description=\"&lt;p&gt;&amp;#8220;amb&amp;#8221; Function&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;&amp;#8220;amb&amp;#8221; Function&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example1.jpg\" class=\"wp-image-2581\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example1.jpg?resize=350%2C406&#038;ssl=1\" alt=\"&quot;amb&quot; Function\" width=\"350\" height=\"406\" \/><\/a><figcaption id=\"caption-attachment-2581\" class=\"wp-caption-text\"><strong>&#8220;amb&#8221; Function<\/strong><\/figcaption><\/figure>\n<p>Nothing fancy here, since it is quite easy to implement this behavior using <em><strong>&#8220;rand&#8221;<\/strong><\/em> function. However, given that it is available by default, we have a ready-made starting point for implementing non-deterministic functionality in our code. The important thing to remember is that only one of the arguments is evaluated. Since function arguments could be arbitrary expressions, we do not want to evaluate them unnecessarily even though only one of them is <em><strong>&#8220;returned&#8221;<\/strong><\/em> as result. The <em><strong>&#8220;amb&#8221;<\/strong><\/em> function handles this correctly. See the following example:<\/p>\n<figure id=\"attachment_2582\" aria-describedby=\"caption-attachment-2582\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example2.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2582\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/10\/17\/some-interesting-features-of-newlisp\/example2-20\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example2.jpg\" data-orig-size=\"529,218\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1634462832&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Avoiding Unnecessary Evaluation\" data-image-description=\"&lt;p&gt;Avoiding Unnecessary Evaluation&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Avoiding Unnecessary Evaluation&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example2.jpg\" class=\"wp-image-2582\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example2.jpg?resize=500%2C206&#038;ssl=1\" alt=\"Avoiding Unnecessary Evaluation\" width=\"500\" height=\"206\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example2.jpg?resize=300%2C124&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/example2.jpg?w=529&amp;ssl=1 529w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2582\" class=\"wp-caption-text\"><strong>Avoiding Unnecessary Evaluation<\/strong><\/figcaption><\/figure>\n<p>The first value printed is from argument evaluation and the second value is the final result. You can see that both are the same.<\/p>\n<p>If you are curious, here is one way to implement the functionality provided by <em><strong>&#8220;amb&#8221;<\/strong><\/em>:<\/p>\n<figure id=\"attachment_2583\" aria-describedby=\"caption-attachment-2583\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/my-amb.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2583\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/10\/17\/some-interesting-features-of-newlisp\/my-amb\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/my-amb.jpg\" data-orig-size=\"780,125\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1634492162&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Possible Implementation of &amp;#8220;amp&amp;#8221;\" data-image-description=\"&lt;p&gt;Possible Implementation of &amp;#8220;amp&amp;#8221;&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Possible Implementation of &amp;#8220;amp&amp;#8221;&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/my-amb.jpg\" class=\"wp-image-2583\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/my-amb.jpg?resize=550%2C88&#038;ssl=1\" alt=\"Possible Implementation of &quot;amp&quot;\" width=\"550\" height=\"88\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/my-amb.jpg?resize=300%2C48&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/my-amb.jpg?resize=768%2C123&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/my-amb.jpg?w=780&amp;ssl=1 780w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-2583\" class=\"wp-caption-text\"><strong>Possible Implementation of &#8220;amb&#8221;<\/strong><\/figcaption><\/figure>\n<p>I am using a <em><strong>&#8220;macro&#8221;<\/strong><\/em> to suppress normal argument evaluation. Quite straightforward.<\/p>\n<h3>Functions with State<\/h3>\n<p><em><strong>newLisp<\/strong><\/em> supports the notion of <em><strong>&#8220;Namespace&#8221;<\/strong><\/em> or <em><strong>&#8220;Context&#8221;<\/strong><\/em>. Based on this idea, it is possible to use a simple <em><strong>&#8220;trick&#8221;<\/strong><\/em> to associate <em><strong>&#8220;state&#8221;<\/strong><\/em> with functions.<\/p>\n<p>Let us write a function that returns successive even numbers starting from zero.<\/p>\n<figure id=\"attachment_2584\" aria-describedby=\"caption-attachment-2584\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2584\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/10\/17\/some-interesting-features-of-newlisp\/nexteven\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven.jpg\" data-orig-size=\"664,186\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1634481938&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Generating Even Numbers\" data-image-description=\"&lt;p&gt;Generating Even Numbers&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Generating Even Numbers&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven.jpg\" class=\"wp-image-2584\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven.jpg?resize=500%2C140&#038;ssl=1\" alt=\"Generating Even Numbers\" width=\"500\" height=\"140\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven.jpg?resize=300%2C84&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven.jpg?w=664&amp;ssl=1 664w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2584\" class=\"wp-caption-text\"><strong>Generating Even Numbers<\/strong><\/figcaption><\/figure>\n<p>Here, <em><strong>NextEven:NextEven<\/strong><\/em> is called a <em><strong>&#8220;default function&#8221;<\/strong><\/em> since it has the same name as its namespace, that is, <em><strong>&#8220;NextEven&#8221;<\/strong><\/em>. <em><strong>NextEven:curvalue<\/strong><\/em> is a <em><strong>&#8220;static&#8221;<\/strong><\/em> variable within the same namespace. The <em><strong>NextEven<\/strong><\/em> function uses this <em><strong>&#8220;lexically isolated&#8221;<\/strong><\/em> variable to save its state across invocations.<\/p>\n<p>Here is what happens when you execute the <em><strong>NextEven<\/strong><\/em> function:<\/p>\n<figure id=\"attachment_2585\" aria-describedby=\"caption-attachment-2585\" style=\"width: 375px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven-result.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2585\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/10\/17\/some-interesting-features-of-newlisp\/nexteven-result\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven-result.jpg\" data-orig-size=\"288,241\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1634481985&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Result of Calling NextEven\" data-image-description=\"&lt;p&gt;Result of Calling NextEven&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Result of Calling NextEven&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven-result.jpg\" class=\"wp-image-2585\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/NextEven-result.jpg?resize=375%2C314&#038;ssl=1\" alt=\"Result of Calling NextEven\" width=\"375\" height=\"314\" \/><\/a><figcaption id=\"caption-attachment-2585\" class=\"wp-caption-text\"><strong>Calling NextEven<\/strong><\/figcaption><\/figure>\n<p>Thus, everytime the function is called, it correctly returns the <em><strong>&#8220;next&#8221;<\/strong><\/em> even number.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>What if we want to start from <em><strong>Zero<\/strong><\/em> again? No worries! We can write another <em><strong>&#8220;helper&#8221;<\/strong><\/em> function in the same <em><strong>&#8220;context&#8221;<\/strong><\/em> to reset the static variable. Here is how:<\/p>\n<figure id=\"attachment_2586\" aria-describedby=\"caption-attachment-2586\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2586\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/10\/17\/some-interesting-features-of-newlisp\/reset\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset.jpg\" data-orig-size=\"626,156\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1634485055&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Resetting the State\" data-image-description=\"&lt;p&gt;Resetting the State&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Resetting the State&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset.jpg\" class=\"wp-image-2586\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset.jpg?resize=500%2C125&#038;ssl=1\" alt=\"Resetting the State\" width=\"500\" height=\"125\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset.jpg?resize=300%2C75&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset.jpg?w=626&amp;ssl=1 626w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-2586\" class=\"wp-caption-text\"><strong>Resetting the State<\/strong><\/figcaption><\/figure>\n<p>Here is an execution sequence showing the <em><strong>&#8220;Reset&#8221;<\/strong><\/em> logic:<\/p>\n<figure id=\"attachment_2587\" aria-describedby=\"caption-attachment-2587\" style=\"width: 375px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset-result.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2587\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2021\/10\/17\/some-interesting-features-of-newlisp\/reset-result\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset-result.jpg\" data-orig-size=\"332,196\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1634485023&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Reset in Action\" data-image-description=\"&lt;p&gt;Reset in Action&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Reset in Action&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset-result.jpg\" class=\"wp-image-2587\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset-result.jpg?resize=375%2C221&#038;ssl=1\" alt=\"Reset in Action\" width=\"375\" height=\"221\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset-result.jpg?resize=300%2C177&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/10\/Reset-result.jpg?w=332&amp;ssl=1 332w\" sizes=\"(max-width: 375px) 100vw, 375px\" \/><\/a><figcaption id=\"caption-attachment-2587\" class=\"wp-caption-text\"><strong>Reset in Action<\/strong><\/figcaption><\/figure>\n<p>Elegant, isn&#8217;t it? Note that we cannot just use the syntax\u00a0<em><strong>(Reset)<\/strong><\/em> unless the current context is <em><strong>NextEven <\/strong><\/em>(more about contexts in a future article).<\/p>\n<p>These are the two features I wanted to discuss today. There are many more appealing features in <em><strong>&#8220;newLisp&#8221;<\/strong><\/em> and I will try to cover some of them in future articles.<\/p>\n<p>The version of newLisp I used is <em><strong>10.7.5 (64 bit)<\/strong><\/em> running on <em><strong>Windows 10<\/strong><\/em>.<\/p>\n<p>Have a nice weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>newLisp is a general-purpose scripting language with a Lisp-like syntax. That is one of the reasons I wanted to take a closer look at the language. It has a compact footprint, small resource requirements, and can easily be embedded. It is available on multiple platforms, and on my Windows machine, the installation has just two [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[297,17],"tags":[298],"class_list":["post-2580","post","type-post","status-publish","format-standard","hentry","category-newlisp","category-programming","tag-newlisp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-FC","jetpack-related-posts":[{"id":2610,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/11\/14\/currying-in-newlisp\/","url_meta":{"origin":2580,"position":0},"title":"Currying in &#8220;newLisp&#8221;","author":"admin","date":"November 14, 2021","format":false,"excerpt":"In the last two articles, I discussed what I believe are some interesting features of \"newLisp\". Today's topic is \"currying\", another useful feature. For those of you who are new to this topic, I had earlier written about \"currying\" in Mathematica here. You may want to take a look at\u2026","rel":"","context":"In &quot;newLisp&quot;","block_context":{"text":"newLisp","link":"https:\/\/www.rangakrish.com\/index.php\/category\/newlisp\/"},"img":{"alt_text":"Example of Currying","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/11\/Example1-300x141.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2632,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/12\/12\/the-net-eval-function-in-newlisp\/","url_meta":{"origin":2580,"position":1},"title":"The &#8220;net-eval&#8221; Function in &#8220;newLisp&#8221;","author":"admin","date":"December 12, 2021","format":false,"excerpt":"One of the cool\u00a0things about \"newLisp\" is that despite its small fooprint, it comes with a lot of functionality built-in. For instance, if you are interested in distributed computing, it is pretty easy to get started. In this article, I will touch upon the net-eval function\u00a0that allows an expression to\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Two Servers","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Servers-300x253.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2620,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/11\/28\/understanding-the-unify-function-in-newlisp\/","url_meta":{"origin":2580,"position":2},"title":"Understanding the &#8220;unify&#8221; Function in &#8220;newLisp&#8221;","author":"admin","date":"November 28, 2021","format":false,"excerpt":"Unification between two symbolic expressions involves finding substitutions for variables (if any) in the expressions such that the expressions match\u00a0after applying the substitutions. This is a powerful idea and is quite common in logic programming languages such as Prolog. Interestingly, \"newLisp\" has a buil-in function called \"unify\" that can be\u2026","rel":"","context":"In &quot;newLisp&quot;","block_context":{"text":"newLisp","link":"https:\/\/www.rangakrish.com\/index.php\/category\/newlisp\/"},"img":{"alt_text":"Unifying \"atomic\" expressions","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/11\/Example1-1-300x106.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2593,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/11\/01\/implicit-indexing-and-slicing-in-newlisp\/","url_meta":{"origin":2580,"position":3},"title":"Implicit Indexing and Slicing in &#8220;newLisp&#8221;","author":"admin","date":"November 1, 2021","format":false,"excerpt":"In traditional Lisp (Common Lisp), when evaluating an S-expression list, the first element in the \"functor\" position must be a function or valid operator. newLisp\u00a0relaxes this requirement and allows the first element to be a context symbol type, a list, an array, or an integer. For today's discussion, let us\u2026","rel":"","context":"In &quot;newLisp&quot;","block_context":{"text":"newLisp","link":"https:\/\/www.rangakrish.com\/index.php\/category\/newlisp\/"},"img":{"alt_text":"List Indexing","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/11\/list1-300x141.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2645,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/12\/25\/calling-lisp-functions-from-d-language\/","url_meta":{"origin":2580,"position":4},"title":"Calling Lisp Functions from D Language","author":"admin","date":"December 25, 2021","format":false,"excerpt":"After exploring \"newLisp\" in the past few posts, I would like to start looking at the \"D Programming Language\"\u00a0(DLang). DLang\u00a0has been around since 2001. It was originally created by Walter Bright and later Andrei Alexandrescu joined the team in 2007. The main inspiration for DLang was C++, although it uses\u2026","rel":"","context":"In &quot;D Language&quot;","block_context":{"text":"D Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/d-language\/"},"img":{"alt_text":"Lisp Function Called from D","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/12\/Lisp-300x107.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":653,"url":"https:\/\/www.rangakrish.com\/index.php\/2017\/10\/14\/using-function-calls-in-the-grammar\/","url_meta":{"origin":2580,"position":5},"title":"Using Function Calls in the Grammar","author":"admin","date":"October 14, 2017","format":false,"excerpt":"One of the advanced features of iLangGen is the ability to embed arbitrary function calls on the RHS of grammar rules. Such functions impart interesting dynamic behaviour to the generated data. For convenience and flexibility, iLangGen supports two types of function calls - Direct and Indirect. In the case of\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Direct Function Call in Grammar","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/10\/Image1.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=2580"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/2580\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=2580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=2580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=2580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}