{"id":3199,"date":"2023-09-04T09:01:10","date_gmt":"2023-09-04T03:31:10","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=3199"},"modified":"2023-09-04T09:04:20","modified_gmt":"2023-09-04T03:34:20","slug":"simulating-python-zip-in-lisp","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/","title":{"rendered":"Simulating Python Zip in Lisp"},"content":{"rendered":"<p>The <em><strong>zip()<\/strong><\/em> function in <a href=\"https:\/\/realpython.com\/python-zip-function\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Python<\/strong><\/em><\/a> is a convenient mechanism for iterating over multiple <em><strong>\u201citerables\u201d<\/strong><\/em> in parallel. Looping over lists is a common scenario.<\/p>\n<figure id=\"attachment_3200\" aria-describedby=\"caption-attachment-3200\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-code.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"3200\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/python-code\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-code.jpg\" data-orig-size=\"662,219\" 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;1693721036&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=\"Python Zip() Feature\" data-image-description=\"&lt;p&gt;Python Zip() Feature&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Python Zip() Feature&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-code.jpg\" class=\"wp-image-3200\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-code.jpg?resize=500%2C165&#038;ssl=1\" alt=\"Python Zip() Feature\" width=\"500\" height=\"165\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-code.jpg?resize=300%2C99&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-code.jpg?w=662&amp;ssl=1 662w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-3200\" class=\"wp-caption-text\"><strong>Python Zip() Feature<\/strong><\/figcaption><\/figure>\n<p>Here is the output generated by the above code:<\/p>\n<figure id=\"attachment_3201\" aria-describedby=\"caption-attachment-3201\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-example.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3201\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/python-example\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-example.jpg\" data-orig-size=\"755,169\" 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;1693720996&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=\"Python Output\" data-image-description=\"&lt;p&gt;Python Output&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Python Output&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-example.jpg\" class=\"wp-image-3201\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-example-300x67.jpg?resize=550%2C123&#038;ssl=1\" alt=\"Python Output\" width=\"550\" height=\"123\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-example.jpg?resize=300%2C67&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-example.jpg?w=755&amp;ssl=1 755w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3201\" class=\"wp-caption-text\"><strong>Python Output<\/strong><\/figcaption><\/figure>\n<p><em><strong>Common Lisp<\/strong><\/em> does not have such a feature built into the language or as part of the standard library. Of course, we have the expressive <em><strong>\u201cloop\u201d<\/strong> <\/em>construct that allows us to iterate over multiple lists, etc. Here is an example that traverses multiple lists:<\/p>\n<figure id=\"attachment_3202\" aria-describedby=\"caption-attachment-3202\" style=\"width: 320px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/Basic-lisp.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3202\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/basic-lisp\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/Basic-lisp.jpg\" data-orig-size=\"524,324\" 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;1693652367&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=\"Common Lisp Loop Function\" data-image-description=\"&lt;p&gt;Common Lisp Loop Function&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Common Lisp Loop Function&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/Basic-lisp.jpg\" class=\"wp-image-3202\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/Basic-lisp.jpg?resize=320%2C198&#038;ssl=1\" alt=\"Common Lisp Loop Function\" width=\"320\" height=\"198\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/Basic-lisp.jpg?resize=300%2C185&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/Basic-lisp.jpg?w=524&amp;ssl=1 524w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/a><figcaption id=\"caption-attachment-3202\" class=\"wp-caption-text\"><strong>Common Lisp Loop Function<\/strong><\/figcaption><\/figure>\n<p>It is not difficult to program the<em><strong> zip()<\/strong> <\/em>functionality in <em><strong>Lisp<\/strong><\/em>. In this article, I will show two ways to do this. For the sake of brevity, I am going to focus on <em><strong>lists<\/strong><\/em> as arguments to <em><strong>zip()<\/strong><\/em>.<\/p>\n<h3>Using Function Closure<\/h3>\n<p>Our first implementation takes advantage of <em><strong>Lisp<\/strong><\/em>\u2019s <em><strong>\u201cclosure\u201d<\/strong><\/em>, where we return an anonymous function from a function. The anonymous function stores its state in the enclosing function\u2019s variables. Here is the code:<\/p>\n<figure id=\"attachment_3203\" aria-describedby=\"caption-attachment-3203\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-code.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3203\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/closure-code\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-code.jpg\" data-orig-size=\"897,486\" 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;1693649528&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=\"Closure-based Implementation\" data-image-description=\"&lt;p&gt;Closure-based Implementation&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Closure-based Implementation&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-code.jpg\" class=\"wp-image-3203\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-code.jpg?resize=550%2C298&#038;ssl=1\" alt=\"Closure-based Implementation\" width=\"550\" height=\"298\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-code.jpg?resize=300%2C163&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-code.jpg?resize=768%2C416&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-code.jpg?w=897&amp;ssl=1 897w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3203\" class=\"wp-caption-text\"><strong>Closure-based Implementation<\/strong><\/figcaption><\/figure>\n<p>The <em><strong>zip()<\/strong><\/em> function takes multiple lists as its arguments and returns a function that captures this state. Every time this function is called, it will return the next sequence from the list. For convenience and readability, I have also defined the <em><strong>next()<\/strong><\/em> function (as a macro) that returns the next element. It returns <em><strong>\u201cnil\u201d<\/strong><\/em> when the entire collection has been traversed.<\/p>\n<p>The following shows an interactive session that uses the <em><strong>zip()<\/strong><\/em> function:<\/p>\n<figure id=\"attachment_3204\" aria-describedby=\"caption-attachment-3204\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-example.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3204\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/closure-example\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-example.jpg\" data-orig-size=\"982,749\" 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;1693649428&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=\"Using Closure-based Implementation\" data-image-description=\"&lt;p&gt;Using Closure-based Implementation&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Using Closure-based Implementation&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-example.jpg\" class=\"wp-image-3204\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-example-300x229.jpg?resize=550%2C420&#038;ssl=1\" alt=\"Using Closure-based Implementation\" width=\"550\" height=\"420\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-example.jpg?resize=300%2C229&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-example.jpg?resize=768%2C586&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/closure-example.jpg?w=982&amp;ssl=1 982w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3204\" class=\"wp-caption-text\"><strong>Using Closure-based Implementation<\/strong><\/figcaption><\/figure>\n<p>Note that the function correctly handles the case when not all lists are of the same size.<\/p>\n<h3>Using \u201cstruct\u201d Abstraction<\/h3>\n<p>Yet another (in my view, better) approach is to wrap the <em><strong>zip()<\/strong> <\/em>functionality around a class\/struct. I have chosen <em><strong>struct<\/strong> <\/em>because that is sufficient for our case. Here is the code:<\/p>\n<figure id=\"attachment_3206\" aria-describedby=\"caption-attachment-3206\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-code.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3206\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/defstruct-code\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-code.jpg\" data-orig-size=\"939,574\" 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;1693721508&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=\"Using Defstruct\" data-image-description=\"&lt;p&gt;Using Defstruct&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Using Defstruct&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-code.jpg\" class=\"wp-image-3206\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-code.jpg?resize=550%2C336&#038;ssl=1\" alt=\"Using Defstruct\" width=\"550\" height=\"336\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-code.jpg?resize=300%2C183&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-code.jpg?resize=768%2C469&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-code.jpg?w=939&amp;ssl=1 939w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3206\" class=\"wp-caption-text\">U<strong>sing Defstruct<\/strong><\/figcaption><\/figure>\n<p>Our <em><strong>struct<\/strong><\/em> contains just one instance variable called <em><strong>\u201celements<\/strong><\/em>\u201d to keep track of the supplied collection. The main <em><strong>zip()<\/strong><\/em> method calls the constructor to instantiate a new object. As earlier, the <em><strong>next()<\/strong><\/em> method returns the next set of elements and return <em><strong>\u201cnil\u201d<\/strong><\/em> when the collection is fully traversed. I have also defined two convenience methods s<em><strong>ize()<\/strong> <\/em>and <em><strong>remaining()<\/strong><\/em>. The former returns the number of pending items and the latter returns all remaining items from the sequence.<\/p>\n<p>The following shows its usage:<\/p>\n<figure id=\"attachment_3207\" aria-describedby=\"caption-attachment-3207\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-example.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3207\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/defstruct-example\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-example.jpg\" data-orig-size=\"753,925\" 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;1693662517&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=\"Using Defstruct Version\" data-image-description=\"&lt;p&gt;Using Defstruct Version&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Using Defstruct Version&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-example.jpg\" class=\"wp-image-3207\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-example-244x300.jpg?resize=400%2C491&#038;ssl=1\" alt=\"Using Defstruct Version\" width=\"400\" height=\"491\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-example.jpg?resize=244%2C300&amp;ssl=1 244w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/defstruct-example.jpg?w=753&amp;ssl=1 753w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-3207\" class=\"wp-caption-text\"><strong>Using Defstruct Version<\/strong><\/figcaption><\/figure>\n<p>It is possible to extend the implementation to cover other collections such as arrays, dictionaries, etc.<\/p>\n<p>I have tested this implementation in <em><strong><a href=\"http:\/\/www.lispworks.com\/products\/lispworks.html\" target=\"_blank\" rel=\"noopener\">LispWorks Enterprise<\/a> 8.0.1, 64 bit<\/strong><\/em> edition on <em><strong>Windows 10<\/strong><\/em>. Here is the <a href=\"https:\/\/www.rangakrish.com\/downloads\/zip-function.lisp\" target=\"_blank\" rel=\"noopener\"><em><strong>source code<\/strong><\/em><\/a>.<\/p>\n<p>Have a nice week!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The zip() function in Python is a convenient mechanism for iterating over multiple \u201citerables\u201d in parallel. Looping over lists is a common scenario. Here is the output generated by the above code: Common Lisp does not have such a feature built into the language or as part of the standard library. Of course, we have [&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":[18,17,103],"tags":[110,208,367],"class_list":["post-3199","post","type-post","status-publish","format-standard","hentry","category-lisp","category-programming","category-python","tag-common-lisp","tag-python","tag-zip"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-PB","jetpack-related-posts":[{"id":3312,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/01\/28\/the-hy-programming-language\/","url_meta":{"origin":3199,"position":0},"title":"The Hy Programming Language","author":"admin","date":"January 28, 2024","format":false,"excerpt":"In an earlier article\u00a0I had explained how to execute Python code from within Common Lisp using \u201cCLPython\u201d package. In contrast to that approach, \u201cHy\u201d\u00a0is a Lisp-style language (not compatible with Common Lisp) that is embedded in Python and hence provides seamless interoperability with Python code. Installation is straightforward (it is\u2026","rel":"","context":"In &quot;Hy Language&quot;","block_context":{"text":"Hy Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/hy-language\/"},"img":{"alt_text":"Hy REPL","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/01\/console-300x148.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":558,"url":"https:\/\/www.rangakrish.com\/index.php\/2017\/07\/07\/clpython-python-in-common-lisp\/","url_meta":{"origin":3199,"position":1},"title":"CLPython &#8211; Python in Common Lisp","author":"admin","date":"July 7, 2017","format":false,"excerpt":"My work in the area of NLP requires\u00a0me to work with several frameworks across multiple languages such as Java, Python and Lisp. Sometime ago I got a chance to experiment with CLPython, an open-source implementation of Python in Common Lisp. Although CLPython is not under active development now, I found\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":567,"url":"https:\/\/www.rangakrish.com\/index.php\/2017\/07\/22\/clpython-python-in-common-lisp-part-2\/","url_meta":{"origin":3199,"position":2},"title":"CLPython: Python in Common Lisp &#8211; Part 2","author":"admin","date":"July 22, 2017","format":false,"excerpt":"We looked at the basic features of CLPython\u00a0in our last blog. In today's post let us look at the support for Python classes. PYTEST 130 > (defun pyclass () \u00a0 (run\u00a0 \"class Employee: \u00a0\u00a0 def __init__(self, name, dept): \u00a0\u00a0 \u00a0 self.name = name \u00a0\u00a0 \u00a0 self.dept = dept \u00a0\u00a0 def\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1560,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/05\/05\/python-integration-in-mathematica-12\/","url_meta":{"origin":3199,"position":3},"title":"Python Integration in Mathematica 12","author":"admin","date":"May 5, 2019","format":false,"excerpt":"Mathematica has had Python support since ver 11.2 through ExternalEvaluate[]. In ver 11.3 it was possible to input Python expression in a cell by beginning with \u201c>\u201d character. The good news is that Mathematica 12 has significantly enhanced this integration. Python Cells Let us start with the simplest way to\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Function References","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3399,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/06\/08\/kp-astrology-rest-server-part-2\/","url_meta":{"origin":3199,"position":4},"title":"KP Astrology REST Server: Part 2","author":"admin","date":"June 8, 2024","format":false,"excerpt":"In my earlier article, I had briefly described the REST server I wanted to build for Krishnamurti Padhdhati system of astrology. After a long time I have managed to complete the implementation and it is now ready for deployment. In this article, I will go over some of its features\u2026","rel":"","context":"In &quot;Astrology&quot;","block_context":{"text":"Astrology","link":"https:\/\/www.rangakrish.com\/index.php\/category\/astrology\/"},"img":{"alt_text":"KPRest Application Window","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/06\/Start-300x174.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3350,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/09\/the-hy-programming-language-part-2\/","url_meta":{"origin":3199,"position":5},"title":"The Hy Programming Language &#8211; Part 2","author":"admin","date":"March 9, 2024","format":false,"excerpt":"I wrote about \u201cHy\u201d language in an earlier article. Since then I have been exploring the language some more, trying to get a better understanding of its features.\u00a0 The following example uses inheritance to model different types of \u201cSpace\u201d objects such as Asteroid, SpaceShip and Planet. It is taken from\u2026","rel":"","context":"In &quot;Hy Language&quot;","block_context":{"text":"Hy Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/hy-language\/"},"img":{"alt_text":"Inheritance Example","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/Inheritance-Example-201x300.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/Inheritance-Example-201x300.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/Inheritance-Example-201x300.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3199","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=3199"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3199\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=3199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=3199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=3199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}