tag:blogger.com,1999:blog-1506645095464847642.post8307737231145787715..comments2023-10-24T07:25:47.647-07:00Comments on Clojure & lx: What makes Clojure different?Anonymoushttp://www.blogger.com/profile/05181838563129459294noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-1506645095464847642.post-5759281528705990692012-02-17T09:47:25.863-08:002012-02-17T09:47:25.863-08:00Just to follow up, i've made a bit of progress...Just to follow up, i've made a bit of progress. I now realise I have to have the negation of the first case in conde (that's just the way conde works), also I was needlessly recurring (unless we are going to have people called "Mr Sir Martin Jones", I just need to strip the prefix.<br /><br />(defne first-nameo [f n]<br /> ([a [h . t]]<br /> (fresh [b]<br /> (membero h prefixes)<br /> (firsto t a)))<br /> ([a [a . _]]<br /> (conda<br /> [(membero a prefixes) u#]<br /> [s#])))<br /><br />(run* [q]<br /> (fresh [n]<br /> (membero n names)<br /> (first-nameo q n)))<br /><br />(run* [q]<br /> (first-nameo "Martin" q)) ;; Gives full names that could have Martin as a prefixAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1506645095464847642.post-13369803900542893002012-02-13T02:33:33.558-08:002012-02-13T02:33:33.558-08:00Thank you for your series of blog posts - really g...Thank you for your series of blog posts - really getting a lot of out them. <br />I'm just starting to look at core.logic and took this post as inspiration.<br />I have tried to implement your first-name function in core.logic, and thought it would be good to share:<br /><br />It works, but I am unhappy with having to define the two cases of 'prefix' and 'not prefix' redundantly (i.e how would I do this as an else), also not sure if my not-prefixo is good style.<br /><br />Anyway, thanks for your enjoyable blog posts,<br /><br />Martin<br /><br />(defn not-prefixo [x]<br /> (conda<br /> [(membero x prefixes) u#]<br /> [s#]))<br /><br />(defne first-nameo [f n]<br /> ([a [h . t]]<br /> (membero h prefixes)<br /> (first-nameo a t))<br /> ([a [a . _]]<br /> (not-prefixo a)))<br /><br />(run* [q]<br /> (fresh [n]<br /> (membero n names)<br /> (first-nameo q n)))<br /><br />(run 1 [q]<br /> (first-nameo "Martin" q)) ;; It would be cool if this gave names with all the prefix options tooAnonymousnoreply@blogger.com