Re: Belgian Clojure base meetup?
I'd love to see a Belgian Clojure meetup! I'm from Antwerp. Kind regards, Frederik -- 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
Re: Combining maps and finite domains in core.logic returns only one result
FYI this works with vectors: (run* [q] (fresh [x] (infd x (interval 1 3)) (== q [x]))) ;=> ([1] [2] [3]) But lcons seems to fail as well: (run* [q] (fresh [x] (infd x (interval 1 3)) (== q (lcons x 'foo ;=> ((1 . foo)) Kind regards, Frederik -- 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
Combining maps and finite domains in core.logic returns only one result
Hey, I'm trying to combine maps with finite domains with some odd results. A simple query using finite domains correctly returns all values: (run* [q] (fresh [x] (infd x (interval 1 3)) (== q x))) ;=> (1 2 3) But putting this result in a map returns only the first value: (run* [q] (fresh [x] (infd x (interval 1 3)) (== q {:foo x}))) ;=> ({:foo 1}) Am I missing something? I'm using core.logic 0.8.0-beta2 on clojure 1.4.0. Kind regards, Frederik -- 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
Re: Using a dynamic number of lvars in core.logic.
I had some trouble because all goals need to take in the list of lvars. `infd` doesn't take in a list, but your sudoku blog post has `all-infd` which does the trick: (defn all-infd "Assign a domain to all vars." [vars domain] (if (seq vars) (all (domfd (first vars) domain) (all-infd (next vars) domain)) succeed)) Which means that `distinct-numbers` can be written as such: (defn distinct-numbers [n min max] "Generate all combinations of n numbers between min and max." (run* [q] (let [vars (repeatedly n lvar)] (all (all-infd vars (interval min max)) (distinctfd vars) (== q vars) user=> (distinct-numbers 3 6 8) ((6 7 8) (6 8 7) (7 6 8) (7 8 6) (8 6 7) (8 7 6)) Thanks for the help! Frederik > > -- 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
Re: Using a dynamic number of lvars in core.logic.
Hey David, I don't quite understand how I would apply your suggestion this with my example. 1. So the "all" function creates a choice point. How do I create lvars? I tried: (run* [q] (let [vars (repeatedly 3 #(gensym 'x))] (all (== q vars ;=> ((x4388 x4389 x4390)) Shouldn't I get unbound lvars ((_.0 _.1 _.2)) back? What type should an lvar be? 2. How do I call the other goals, like infd and distinctfd? I tried: (run* [q] (let [vars (repeatedly 5 #(gensym 'x))] (all (infd vars (interval 1 3)) (distinctfd vars) (== q vars But this gave an error: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.Number at clojure.lang.Numbers.gte (Numbers.java:231) clojure.core.logic.IntervalFD.member_QMARK_ (logic.clj:499) clojure.core.logic$process_dom$fn__3874.invoke (logic.clj:2959) clojure.core.logic$composeg$fn__3102.invoke (logic.clj:1516) clojure.core.logic$domfd$fn__3877.invoke (logic.clj:2971) clojure.core.logic.Substitutions.bind (logic.clj:1051) functional programming FTW ;) > I'd love to apply what I've learned about Clojure – but for now, once I'm in a "run*" I enter a mystical land of fairies and butterflies where none of the functional rules apply :-) Thanks for your help, Frederik -- 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
Using a dynamic number of lvars in core.logic.
Using core.logic, I sometimes have the need to create a variable number of fresh lvars. For example, I want to create all possible combinations of "n" numbers between "min" and "max". Currently the only way I found how to do this was building the expression and evalling it: (defn generate-symbols [n] (for [i (range 0 n)] (gensym 'x))) (defn distinct-numbers [n min max] (let [lvars (generate-symbols n)] (eval `(run* [q#] (fresh [~@lvars] (infd ~@lvars (interval ~min ~max)) (distinctfd [~@lvars]) (== q# [~@lvars])) Is there a better way to do this? Kind regards, Frederik -- 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
Re: help choosing dev environment for clojure
+ 1 for Light Table. The instarepl is a very useful tool for learning and exploring Clojure. F Op zondag 25 november 2012 22:00:36 UTC+1 schreef René Groß het volgende: > > You could consider lighttable by chris granger as well. It is at a very > early stage, but pretty much usable for hacking some clojure. -- 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
Re: refer-clojure seems to have no effect.
> Just use a different namespace. > > Thanks! That did the trick. Regards, Frederik -- 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
refer-clojure seems to have no effect.
Hi, I'm trying to use core.logic using the following namespace expression (modelled on core.logic's own test file): (ns user (:refer-clojure :exclude [==]) (:use clojure.core.logic)) However, this gives the following warning: WARNING: == already refers to: #'clojure.core/== in namespace: user, being replaced by: #'clojure.core.logic/== It seems that the "refer-clojure" line has no effect. What am I doing wrong? Kind regards, Frederik -- 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