Ok, so the function (let's name it for-all) is: (defn for-all "A goal that succeeds if all goals succeeds." [goal first-param list] (fresh [head rest] (conso head rest list) (goal first-param head) (for-all goal first-param rest)))
it takes 3 parameters. 1. a goal, 2. first parameter to the goal 3. list of parameters which will be applied as a second one to the goal. The 'for-all' goal succeeds when goal 'goal' succeeds for all pairs: first-param a, first-param b, first-param c ...., where a, b, c, .... are elements of 'list' list. Conso is a goal which takes 3 parameters. 1. an element, 2. list of elements, 3 list of elements. And succeeds when 3rd list is equal to 2nd list with prepended element ( L = H | R ) In goal 'for-all' conso is used for destructuring a 'list' list and store its head and rest in fresh variables. For such obtained head we try to apply 'goal' goal AND continue recursively in the same fashion with the rest of the list. Kind Regards, Daniel Kwiecinski lambder.com On 26 April 2012 23:57, nchurch <nchubr...@gmail.com> wrote: > For the benefit of bystanders, could anyone explain why and how > Daniel's for-all function works? (I've gotten to chapter 4 of TRS.) > > On Apr 26, 2:04 pm, David Nolen <dnolen.li...@gmail.com> wrote: > > core.logic can remember previous results via tabling. > > > > As far as n-queens - that's a problem best left for constraint logic > > programming (CLP). core.logic doesn't have constraint programming > > facilities yet, but I've mentioned the desire to implement cKanren many > > times on this list. > > > > Haven't really considered how CLP and tabling could be combined in > > core.logic - but it's been done elsewhere. > > > > David > > > > On Thu, Apr 26, 2012 at 4:55 PM, Daniel Kwiecinski < > > > > > > > > > > > > > > > > daniel.kwiecin...@gmail.com> wrote: > > > So how would you tackle, lets say n-queen problem on m square board > (for > > > realy huge m) knowing that additional small set of chess pieces can be > > > added to the problem (let's say K K N N B) the new pieces attack > fraction > > > of the board potentially not taken by any queens so far. Some of prev > > > solutions would be no longer valid of course but for sure adding new > pieces > > > will not add new queen placements. It only limits it. Would be it > possible > > > to extend Clojure.logic to reuse prev results, or I should forget > about it > > > and restart search from scratch? > > > > > Daniel > > > On Apr 26, 2012 7:55 PM, "David Nolen" <dnolen.li...@gmail.com> wrote: > > > > >> On Thu, Apr 26, 2012 at 1:38 PM, Daniel Kwiecinski < > > >> daniel.kwiecin...@gmail.com> wrote: > > > > >>> Does it make sense at all to you. > > > > >> Makes sense, but sounds outside the scope of what core.logic currently > > >> does. > > > > >> David > > > > >> -- > > >> You received this message because you are subscribed to the Google > > >> Groups "Clojure" group. > > >> To post to this group, send email to clojure@googlegroups.com > > >> Note that posts from new members are moderated - please be patient > with > > >> your first post. > > >> To unsubscribe from this group, send email to > > >> clojure+unsubscr...@googlegroups.com > > >> For more options, visit this group at > > >>http://groups.google.com/group/clojure?hl=en > > > > > -- > > > You received this message because you are subscribed to the Google > > > Groups "Clojure" group. > > > To post to this group, send email to clojure@googlegroups.com > > > Note that posts from new members are moderated - please be patient with > > > your first post. > > > To unsubscribe from this group, send email to > > > clojure+unsubscr...@googlegroups.com > > > For more options, visit this group at > > >http://groups.google.com/group/clojure?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en