lj Leo Zovic: Zippers And Clj By langnostic.inaimathi.ca Published On :: Fri, 08 May 2020 18:49:52 GMT So recently, I had to use zippers at work. Specifically, the Clojure implementation. There were some close-to-arbitrary transformations I needed to do with some close-to-arbitrary trees and it turned out that zippers were more efficient than the alternatives1.Using them this way, combined with the general state of the world and my free time, finally tipped me into doing some more Common Lisp development. Before, I go any further, let me be clear about something.I Like ClojureSeriously.Its logo is up top in the language bar, I was one of the inaugural members of the Toronto Clojure User Group, I recommend it as a first lisp you should learn, and have for about six years now. I'm also painfully aware of the shortcomings of Common Lisp, and make no excuses for them.However.I don't like the JVM. It's slow as balls, its' deployment options are less than ideal for my purposes, its' error system is at best useless, and Clojure without it is unlikely.Clojurescript build incompatiblities are, if anything, worse2.I don't like the underlying licensing decisions.These are deep reasons to stay away. They're not the sort of thing I can paper over with a library or two. Fixing them would mean a superhuman amount of work poured into the underlying technical and social infrastructure, and I'm not into it. I wouldn't be into it even if the community was interested in heading that way, and near as I can tell, they're not particularly.Whether or not I think you should learn Clojure as your first3 lisp, it definitely wasn't my first lisp. The more uniform, mostly-better-thought-out interface, lack of historical baggage and functional data structures are not enough to pull me all the way over.It is enough for me to start plotting a smash-and-grab of as much of the stuff I like as I can carry. Which is exactly what clj represents. As of this writing, it defines and exports exactly four symbols: if-let, when-let, -> and ->>. This is a tiny beginning of the list, and I fully plan to put something more substantial together using cl-hamt, named-readtables, test-utils and possibly optima. Stay tuned to that repo if you're interested, but it's not the focus today.cl-zipperThe thing that percipitated this thought was having used the Clojure Zipper implementation. So, obviously, this is something I want next time I need to manipulate trees in Common Lisp. The paper is here, and unless you have a terminal phobia of datastructures4, you should go read it. It's six pages, they're light, and one of them taken up by the intro and references.The operations defined in the paper are left, right, up, down, insert_right, insert_left, insert_down and delete. There's a few conveniences defined for the Clojure version, and I've implemented some of my own stuff too. Lets go through the main file in almost-literate style.First up, we have constructors.(defstruct path (left) (path) (right)) (defstruct loc (node) (path) (fn-branch?) (fn-children) (fn-make-node)) ;;;;;;;;;; Constructors (defun zipper (branch? children make-node root) (make-loc :node root :fn-branch? branch? :fn-children children :fn-make-node make-node)) (defmethod make-zipper ((thing list)) (zipper #'listp #'identity (lambda (node children) (declare (ignore node)) children) thing)) (defun make-node (zipper children) (funcall (loc-fn-make-node zipper) zipper children)) You can see influence from both clojure.zip and the paper here. I'm taking the lead from the paper by explicitly separating the path triple our from the loc definition. However, I'm not explicitly defining my own type tree the way that Huet does. Instead, I'm going to be dealing with assorted lisp trees. These could be implemented as lists, vectors, hashes, or any number of other formats. I'm going to implement a few type-distpatching built-ins, including the make-zipper list method above, but the basic zipper function just needs to take an interface as input in the form of branch?, children and make-node arguments. This is the same solution that the Clojure implementation went with, and I see no reason to go a different way. The only material difference is that theirs uses the Clojure metadata system, while I explicitly define slots in the loc structure.Now that we can construct, we need to be able to select.;;;;;;;;;; Selectors (defun branch? (zipper) (funcall (loc-fn-branch? zipper) (loc-node zipper))) (defun children (zipper) (funcall (loc-fn-children zipper) (loc-node zipper))) (defun node (zipper) (loc-node zipper)) (defun path (zipper) (loc-path zipper)) (defun lefts (zipper) (when (loc-path zipper) (reverse (path-left (loc-path zipper))))) (defun rights (zipper) (when (loc-path zipper) (path-right (loc-path zipper)))) The basic navigation is four functions; down, up, left and right;;;;;;;;;; Navigation ;;;;;;;;;;;;;;; Basic navigation (defun down (zipper) (when (children zipper) (let ((fresh (copy-loc zipper))) (setf (loc-node fresh) (first (children zipper)) (loc-path fresh) (make-path :left nil :path (loc-path zipper) :right (rest (children zipper)))) fresh))) (defun up (zipper) (when (path zipper) (let ((fresh (copy-loc zipper))) (setf (loc-node fresh) (make-node zipper (append (reverse (path-left (path zipper))) (cons (loc-node zipper) (path-right (path zipper))))) (loc-path fresh) (path-path (path zipper))) fresh))) (defun left (zipper) (when (and (path zipper) (path-left (path zipper))) (let ((fresh (copy-loc zipper))) (setf (loc-node fresh) (first (path-left (path zipper))) (loc-path fresh) (make-path :left (rest (path-left (path zipper))) :path (path-path (path zipper)) :right (cons (loc-node zipper) (path-right (path zipper))))) fresh))) (defun right (zipper) (when (and (path zipper) (path-right (path zipper))) (let ((fresh (copy-loc zipper))) (setf (loc-node fresh) (first (path-right (path zipper))) (loc-path fresh) (make-path :left (cons (loc-node zipper) (path-left (path zipper))) :path (path-path (path zipper)) :right (rest (path-right (path zipper))))) fresh))) The main difference between this and the paper is that I've chosen nil as my Top representation, which lets me pull the trick of using when to check for the presence of a path, and its' non-Top-ness at the same time.The bad news is that since Common Lisp doesn't have pervasive functional data structures, I have to explicitly copy locs while moving through a tree. The good news is that the copy is fairly light weight. Effectively, I'm copying out a set of 5 pointers, and could get that down to 3 by defining an intermediate struct.Hm.Which I probably should do. Note to self.Out of those, we get three compound navigation functions. With more probably coming soon. Specifically, I found find useful for the work I did. It's easily externally definable, but would be even easier to bundle along. The ones I've already implemented are root, leftmost and rightmost.;;;;;;;;;;;;;;; Compound navigation (defun root (zipper) (if-let (z (while zipper #'up)) (node z))) (defun leftmost (zipper) (while zipper #'left)) (defun rightmost (zipper) (while zipper #'right)) Each of these involve an intermediate call to while. Which isn't a generic macro; it's a function defined in util.lisp... (defun until (zipper f) (let ((z zipper)) (loop for next = (funcall f z) while next when next do (setf z next)) z)) ... As you can see, all it does is repeatedly call a given function on a zipper and return the last non-nil loc result. That's loc, not node, so this doesn't run into the usual Common Lisp conflict of "Did you fail to find a thing, or find the element nil?".That's the traversals done. Next up, we've got modification, without which this library is fairly useless. The basics are replace, delete and the insert/child twins.;;;;;;;;;; Modification (defun replace (zipper node) (let ((fresh (copy-loc zipper))) (setf (loc-node fresh) node) fresh)) (defun delete (zipper) (when (path zipper) (let ((fresh (copy-loc zipper)) (fresh-path (copy-path (loc-path zipper)))) (cond ((rights zipper) (setf (loc-node fresh) (pop (path-right fresh-path)) (loc-path fresh) fresh-path)) ((lefts zipper) (setf (loc-node fresh) (pop (path-left fresh-path)) (loc-path fresh) fresh-path)) (t (setf (loc-path fresh) (path-path fresh-path)))) fresh))) (defun insert-child (zipper node) (replace zipper (make-node zipper (cond ((not (branch? zipper)) (list node (node zipper))) ((children zipper) (cons node (children zipper))) (t (list node)))))) (defun append-child (zipper node) (replace zipper (make-node zipper (cond ((not (branch? zipper)) (list (node zipper) node)) ((children zipper) (append (children zipper) (list node))) (t (list node)))))) (defun insert-left (zipper node) (let ((fresh (copy-loc zipper)) (fresh-path (copy-path (loc-path zipper)))) (push node (path-left fresh-path)) (setf (loc-path fresh) fresh-path) fresh)) (defun insert-right (zipper node) (let ((fresh (copy-loc zipper)) (fresh-path (copy-path (loc-path zipper)))) (push node (path-right fresh-path)) (setf (loc-path fresh) fresh-path) fresh)) The paper defines an insert_down function. It fails on a Leaf node, and otherwise inserts a singleton branch at the given location. The insert/append child functions above also insert nodes at a lower level at the current loc. They give you a choice about whether to insert the new node as the leftmost or rightmost child, and additionally succeed on Leaf nodes by including the leaf value as a child of the new branch.There are, thus far, three compound modification functions; edit, splice-left and splice-right.(defun edit (zipper f &rest args) (replace zipper (apply f (node zipper) args))) (defun splice-left (zipper node-list) (reduce #'insert-left node-list :initial-value zipper)) (defun splice-right (zipper node-list) (reduce #'insert-right (reverse node-list) :initial-value zipper)) edit takes a function instead of a new node, and replaces the node at loc with the result of running that function on the existing node. The splice-* twins are fairly self-explanatory; they're like insert-left/insert-right, but work on multiple nodes rather than single ones.I haven't yet implemented next, prev and remove because these might relate to the different representation of the traversal end? state. The reason for this seems to be that next/prev/remove assume a depth-first traversal. The reason I'm being weasely here is that I haven't thought about it hard enough to be sure that the end? marker is really necessary. It also seems odd to privilege depth-first over breadth-first traversals; ideally, I think you'd want to be able to support either. Possibly interchangeably.Minor HousekeepingThat wraps it up for this edition. My immediate intention is to do more work on the cl-zipper and clj libraries, as well as that game I mentioned last time. Ideally, I'd like to up my blogging output too. Probably not to the same volume as I had at my peak, but it was definitely helpful to keep some sort of written journal around for a while. The current state of the world is, hopefully, going to make it easy for me to get more programming time in. All things considered, I'd count that as a win. Although admittedly, it does require me to explain the concept of zippers to a few other people for maintenance purposes. So ironically, this adds complexity despite being much more technically elegant than other options.↩There's a reason that langnostic.js is a raw JS file, rather than compiled from clojurescript source, and that reason is like 90% that the compilation process is nontrivial to set up.↩"First", not "only". You can probably make educated guesses about which other ones I think you should learn.↩In which case, why are you here? This blog could kill you accidentally with an errant click or two. You should probably just go do something else.↩ Full Article
lj Jingle Rails showcases festive trains at Eiteljorg By rssfeeds.indystar.com Published On :: Sun, 23 Dec 2018 22:32:18 +0000 Visitors to the Eiteljorg Museum through January 21 get a chance to see model trains laid out in an intricate winter set in an annual show. Full Article
lj velocityconf: If you don't understand your ppl, you don't understand #Ops http://t.co/DQTBLJlWza New #velocityconf interview w/ @katemats By feedproxy.google.com Published On :: Mon, 20 May 2013 20:26:56 +0000 velocityconf: If you don't understand your ppl, you don't understand #Ops http://t.co/DQTBLJlWza New #velocityconf interview w/ @katemats Full Article
lj CBD Notification SCBD/SSSF/AS/SBG/LJ/88547 (2020-005): Subregional Exchange for the Caribbean on the Restoration of Forests and Other Ecosystems, Castries, Saint Lucia - 9 to 13 March 2020 By www.cbd.int Published On :: Fri, 17 Jan 2020 00:00:00 GMT Full Article
lj Latest Developments in Defamation Law Duffy & Trkulja. By www.catalog.slsa.sa.gov.au Published On :: Full Article
lj School enrolment and attendance measure randomized controlled trial : full report / Rebecca Goldsteinand, Prof. MichaelJ.Hiscox. By www.catalog.slsa.sa.gov.au Published On :: This researchprojectimplemented a randomizedcontrolledtrial ofthe SEAM program in Terms 3 and 4 ofthe 2016 school year. The purpose of the study was to determine the effects of the SEAM program. The study enrolled 448 treatment group students who were referred to SATOs for potential SEAM intervention, and 448 matched control group students who were not referred to SATOs. Approximately one-third of treatment group students received a compulsory conference notice, approximately one-third of treatment students' families signed an attendance plan, about 20% had a compulsory conference take place, and payment was suspended for approximately 5% of treatment students. No significant differences following any of these interventions were observed between treatment and control students. Full Article
lj Observationes et historiae omnes & singulae è Guiljelmi Harvei libello De generatione animalium excerptae ... : Item Wilhelmi Langly De generatione animalium observationes quaedam. Accedunt Ovi faecundi singulis ab incubatione diebus factae inspe By feedproxy.google.com Published On :: Amstelodami : Typis A. Wolfgang, 1674. Full Article
lj BSidesLjubljana 2020 Call For Papers By packetstormsecurity.com Published On :: Wed, 27 Nov 2019 15:39:12 GMT B-Sides Ljubljana will be held April 4th, 2020 in Ljubljana, Slovenia. Full Article
lj Totaljs CMS 12.0 Insecure Admin Session Cookie By packetstormsecurity.com Published On :: Tue, 03 Sep 2019 23:20:22 GMT Totaljs CMS version 12.0 mints an insecure cookie that can be used to crack the administrator password. Full Article
lj KSZ8873MLLJ - Integrated 3-Port 10/100 Managed Switch with PHYs By ww1.microchip.com Published On :: 5/4/2020 5:46:19 PM KSZ8873MLLJ - Integrated 3-Port 10/100 Managed Switch with PHYs Full Article
lj Strictly's Janette Manrara reveals exciting baby plans with Aljaz Skorjanec By www.hellomagazine.com Published On :: Sat, 09 May 20 08:54:09 +0000 It seems Janette Marara has baby fever, and it's all thanks to Gorka Marquez and Gemma... Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government. By feedproxy.google.com Published On :: Jan 22, 2020 Jan 22, 2020Rami Khouri's interview on Aljazeera TV discussing the appointment of the new Lebanese government amidst continuing protests and clashes with police. Full Article
lj Aljasmi: If you don't focus, you will die By www.fifa.com Published On :: Sun, 24 Nov 2019 16:26:00 GMT Full Article
lj Mr. Angel Gurría, Secretary-General of the OECD, in Ljubljana on 4 May 2015 By www.oecd.org Published On :: Mon, 04 May 2015 14:35:00 GMT Mr. Gurría presented the 2015 OECD Economic Survey of Slovenia and met with the Slovenian President, Prime Minister and several government officials. Full Article
lj Nick Kyrgios' US Open love triangle with Ajla Tomljanović and Matteo Berrettini By www.dailymail.co.uk Published On :: Fri, 06 Sep 2019 00:46:19 GMT The Australian bad-boy dated Croatian-Australian tennis ace Ajla Tomljanović for around two years until 2017 - but she appears to have moved on with a rival. Full Article
lj Pride of Britain Awards: Kate Silverton cosies up to Aljaž Škorjanec By Published On :: Tue, 30 Oct 2018 11:24:20 +0000 The BBC journalist, 48, enjoyed a well-deserved break as she joined her partner Aljaž Škorjanec on the red carpet at the Pride Of Britain Awards at London's Grosvenor House Hotel on Monday. Full Article
lj Strictly's Janette Manrara and Aljaz Skorjanec reveal they're broody By www.dailymail.co.uk Published On :: Fri, 13 Mar 2020 14:12:01 GMT The dancing duo, aged 36 and 30, appeared on the ITV chat show to talk about their new dance show Remembering The Oscars. Full Article
lj Soulja Boy says sorry for beef with Chris Brown and insists he wants to 'make music with him' By www.dailymail.co.uk Published On :: Wed, 04 Jan 2017 23:20:55 GMT 'It's not about who start the beefs; it's about who end them.' So said Soulja Boy on Wednesday in a heartfelt apology to his fans for getting embroiled in a social media spat with Chris Brown. Full Article
lj Australian Open chair umpire Marijana Veljovic steals the show By www.dailymail.co.uk Published On :: Sat, 01 Feb 2020 11:25:38 GMT Roger Federer may have caused a stir with an expletive-laden outburst at the Australian Open on Tuesday - but it was the female chair umpire who stole the show. Full Article
lj Vice President meets Kersti Kaljulaid, President of Estonia in Tallinn [ph]Photo Courtesy: Arno Mikkor[/ph] By meacms.mea.gov.in Published On :: Wed, 21 Aug 2019 00:00:00 GMT Full Article
lj President arrives in Ljubljana on last leg of his 3-nation visit to Iceland, Switzerland and Slovenia [ph]Photo Courtesy : PHOTO RB[/ph] By meacms.mea.gov.in Published On :: Sun, 15 Sep 2019 00:00:00 GMT Full Article
lj President meets Dejan Židan, President of the National Assembly of Slovenia in Ljubljana [ph]Photo Courtesy : PHOTO RB[/ph] By meacms.mea.gov.in Published On :: Mon, 16 Sep 2019 00:00:00 GMT Full Article
lj President delivers his address at India-Slovenia Business Forum in Ljubljana, Slovenia [ph]Photo Courtesy : PHOTO RB[/ph] By meacms.mea.gov.in Published On :: Mon, 16 Sep 2019 00:00:00 GMT Full Article
lj President and President of Slovenia witness Signing of Agreements at Presidential Palace, Ljubljana [ph]Photo Courtesy : PHOTO RB[/ph] By meacms.mea.gov.in Published On :: Mon, 16 Sep 2019 00:00:00 GMT Full Article
lj President and President of Slovenia hold Delegation Level Talks at Presidential Palace, Ljubljana [ph]Photo Courtesy : PHOTO RB[/ph] By meacms.mea.gov.in Published On :: Mon, 16 Sep 2019 00:00:00 GMT Full Article
lj President inspects Guard of Honour during his Ceremonial Welcome at Congress Square, Ljubljana [ph]Photo Courtesy : PHOTO RB[/ph] By meacms.mea.gov.in Published On :: Mon, 16 Sep 2019 00:00:00 GMT Full Article
lj President meets Borut Pahor, President of Slovenia at Presidential Palace, Ljubljana [ph]Photo Courtesy : PHOTO RB[/ph] By meacms.mea.gov.in Published On :: Mon, 16 Sep 2019 00:00:00 GMT Full Article
lj President lays wreath at Memorial of the Victims of All Wars at Congress Square, Ljubljana [ph]Photo Courtesy : PHOTO RB[/ph] By meacms.mea.gov.in Published On :: Mon, 16 Sep 2019 00:00:00 GMT Full Article
lj President addresses Indian Community in Ljubljana, Slovenia By meacms.mea.gov.in Published On :: Tue, 17 Sep 2019 00:00:00 GMT Full Article
lj Prime Minister meets Kersti Kaljulaid, President of Estonia on the sidelines of 74th session of UNGA Summit in New York [ph]Photo Courtesy - Lalit Kumar[/ph] By meacms.mea.gov.in Published On :: Wed, 25 Sep 2019 00:00:00 GMT Full Article
lj LJP to contest Bihar elections with development an issue: Chirag Pawan By www.business-standard.com Published On :: Wed, 04 Mar 2020 08:27:00 +0530 He said that if the manifesto is released before the Assembly elections, caste will not be an issue, but the focus will be on development of the state Full Article
lj Watch: Diljeet Dosanjh Impressed by UK Residents Performing Bhangra while Maintaining Social Distancing By www.news18.com Published On :: Sun, 3 May 2020 03:33:46 +0530 As soon as the tweet went viral, netizens including singer-actor Diljit Dosanjh, also expressed his joy in watching the street side bhangra! Full Article
lj Arjun Patiala Movie Review: Diljit Dosanjh, Kriti Sanon's Film is Easily Forgettable By www.news18.com Published On :: Fri, 26 Jul 2019 05:52:06 +0530 Diljit Dosanjh is affable but profoundly bland as Arjun Patiala. Varun Sharma as Arjun's side-kick Onida and Kriti Sanon as Ritu Randhawa are tolerable. Full Article
lj LJP Chief Says Over 14 Lakh People Not Getting Ration Benefits in Bihar, Seeks Nitish Kumar's Response By www.news18.com Published On :: Fri, 24 Apr 2020 01:10:54 +0530 LJP Chief Chirag Paswan said the Bihar government has not issued ration cards amid the coronavirus lockdown despite repeated statements by the Centre Full Article
lj शाहरूख खान की पहली ब्लॉकबस्टर DDLJ - पहना था ऋषि कपूर का चांदनी स्वेटर, वो भी छेद के साथ By hindi.filmibeat.com Published On :: Fri, 01 May 2020 10:00:27 +0530 ऋषि कपूर, यानि कि हिंदी सिनेमा का पहला चॉकलेटी हीरो। मॉडर्न, लड़कियों का दिल जीतने वाला, उन्हें समझने वाला। ऋषि कपूर ने सालों तक अपने इस टैग के साथ राज किया और फिर उन्होंने अपनी ये विरासत सौंप दी शाहरूख खान Full Article
lj Structure data of free polyatomic molecules [Electronic book] / Natalja Vogt, Jürgen Vogt. By encore.st-andrews.ac.uk Published On :: Cham, Switzerland : Springer, [2019] Full Article
lj Islam in Malaysia : an entwined history [Electronic book] / Khairudin Aljunied. By encore.st-andrews.ac.uk Published On :: New York, NY : Oxford University Press, 2019. Full Article
lj International relations in a relational universe [Electronic book] / Milja Kurki. By encore.st-andrews.ac.uk Published On :: Oxford : Oxford University Press, 2020. Full Article
lj Global catastrophic biological risks [Electronic book] / Thomas V. Inglesby, Amesh A. Adalja, editors. By encore.st-andrews.ac.uk Published On :: Cham : Springer, 2019. Full Article
lj Kooljaman at Cape Leveque : a tourism development and marketing strategy / prepared for Bardina Pty Ltd as trustee for the Kooljaman Resort Unit Trust by Ian Menzies of Menzies & Associates By prospero.murdoch.edu.au Published On :: Menzies, Ian, author Full Article
lj Evolution of destination planning and strategy : the rise of tourism in Croatia / Larry Dwyer, Renata Tomljenović, Sanda Ĉorak, editors By prospero.murdoch.edu.au Published On :: Full Article
lj UP panchayat polls: With BJP as ally, LJP to contest elections By indianexpress.com Published On :: Sun, 09 Aug 2015 18:45:36 +0000 Full Article DO NOT USE Uttar Pradesh India