4 ms·
Logic Programming in Clojure
- tom_b 17y agoK, upvoted simply for mentioning The Reasoned Schemer, a book that I'm having great fun simply picking up occasionally. Time to really start cranking on it.
- deleted 17y ago[deleted]
- mark_l_watson 17y agoThe port of mini-Kanren to Clojure is a great contribution - thanks!
- evanrmurphy 17y agoA list can be defined using square-brackets, '[' and ']'. I thought it was funny to do this in Lisp and not represent lists with parens, but I guess it's only syntatic sugar anyway.
- mike_organon 17y agoA list is represented with parens. [] is a vector. There are behavior and performance differences between lists and vectors.
- evanrmurphy 17y agoI don't quite follow, but I'm also new to mini-Kanren. They're called lists in the article and said "to group values or variables so that the collection may referred to as a unit", which sounds like a generic list to me. He compares them to Lisp lists just a couple paragraphs lower. Could you elaborate please?
- chousuke 17y agoMost likely it's a "list" in the DSL, but implemented using Clojure's vectors, which are represented with square brackets and have convenient evaluation semantics (items are evaluated, but it's not a function call), so that it's much more common to use vectors in clojure where one would often type (list foo bar) in CL or perhaps Scheme. Often vectors are used in Clojure DSLs to differentiate from the "operator syntax" which uses actual lists. There are some exceptions in even clojure.core macros, but often you can assume that any unquoted list is evaluated as a function or macro call, even if it is a macro parameter.
- silentbicycle 17y agoBesides The Reasoned Schemer, another excellent logic programming book is _The Art of Prolog_ by Sterling and Shapiro. While it uses Prolog rather than Lisp, it's overall focus is more on Logic Programming than Prolog specifically. It starts with the big ideas in Logic Programming and what they're theoretically capable of, and then shifts to Prolog, the most mainstream implementation of an LP language, and the design trade-offs it has made. (There are other great books more specific to Prolog, if you find you like it.) Also, it has been out of print for a while, and the second edition can be pretty expensive ($90-100ish used). The first edition is much cheaper ($2-5), and while the second covers a newer version of Prolog and greatly expands on the "projects in Prolog" chapters, the first still covers the core LP concepts pretty well.
- tom_b 17y agoStrongly seconded - I started with The Art of Prolog a few months ago and also enjoyed it. Having seen both, I think I'll probably go through the Reasoned Schemer and then return to the Art of Prolog.