Dependency management

2013-10-17 Thread Andrei Serdeliuc
Hi, I was wondering how people handle dependencies that aren't on clojars. We have a couple of clojure libs which are hosted on an internal github enterprise. So far I've been using lein's checkouts feature, but this seems fairly difficult when trying to setup continuous integration. As far as

Re: How create dynamic var programmatically

2012-09-05 Thread Andrei Zhlobich
Try: (.setDynamic (intern *ns* 'a 0)) -- 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 unsubscrib

Re: Why IPersistentList doesn't extend ISeq?

2012-09-03 Thread Andrei Zhlobich
I know it :) Actually clojure has 3 implementations of IPersistentCollection: 1) PersistentList - it is already ISeq 2) EmptyList - it is ISeq (!) https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentList.java#L129 3) PersistentQueue - semantically it it not a list Empty

Re: Why IPersistentList doesn't extend ISeq?

2012-09-03 Thread Andrei Zhlobich
At this time empty list is a valid seq. user => (list? ()) true Sources: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentList.java#L129 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Why IPersistentList doesn't extend ISeq?

2012-09-02 Thread Andrei Zhlobich
Why IPersistentList doesn't extend ISeq? Clojure docs say: >> Lists are collections. They implement the ISeq interface directly (except for the empty list, which is not a valid seq) At this moment EmptyList implements ISeq, but PersistentList doesn't. It seems very strange for me. Also Persist

Why IPersistentList doesn't extend ISeq?

2012-09-02 Thread Andrei Zhlobich
>From docs: >> Lists are collections. They implement the ISeq interface directly (except for the empty list, which is not a valid seq). But at this time IPersistentList does not extend ISeq (but PersistentList does). It sees a bit strange. Also PersistentQueue implements IPersistentList. Seman

Re: How to simplify cond statements

2010-10-30 Thread andrei
On Oct 29, 11:39 pm, Joop Kiefte wrote: > (first (flatten ...)) ? And where reduction of code is? -- 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 mo

Re: How to simplify cond statements

2010-10-29 Thread andrei
On Oct 29, 2:14 pm, Meikel Brandmeyer wrote: > There's nothing stoping you to put a let in a loop. Yes, but imagine a bit more complicated case, for example, instead of '(first (first ps))' write (.foo (first ps)), and it will crash. I'm looking for elegant, but general case template. -- You

Re: How to simplify cond statements

2010-10-29 Thread andrei
On Oct 29, 5:40 am, David Sletten wrote: > You could just bind another local variable in the loop form: > (loop [ps pairs >        ret {} >        ffps (ffirst ps)] >   (cond (empty? ps) ret >         (some-test ffps) (recur (rest ps) (add-to-result ret ffps) (ffirst > (rest ps))) >         :t

Re: How to simplify cond statements

2010-10-29 Thread andrei
On Oct 29, 4:03 am, Andrew Gwozdziewycz wrote: > I'd hoist the empty out of the cond using an if: > > (if (empty? ps) >     ret >     (let [fps (first (first ps))] >         (cond >             ...))) Yeah, I thought about it, but it is still a bit verbose, especially with a 3 conditions loop.

Re: How to simplify cond statements

2010-10-29 Thread andrei
On Oct 29, 4:03 am, lprefonta...@softaddicts.ca wrote: > user=> (doc ffirst) > - > clojure.core/ffirst > ([x]) >   Same as (first (first x)) > nil > user=> > > That could help a bit : Nice! I didn't know about this function, and for this concrete case it is ideal! --

Re: to macro or not?

2010-10-29 Thread andrei
Mike, I mean this is just one example to prove your ideas, not to disprove. On Oct 29, 4:26 am, Mike Meyer wrote: > On Thu, 28 Oct 2010 18:12:39 -0700 (PDT) > > andrei wrote: > > > I'll try to extend Mike's answer by one more example. Consider `and` > > Lisp ma

Re: to macro or not?

2010-10-28 Thread andrei
I'll try to extend Mike's answer by one more example. Consider `and` Lisp macro. It is not a function, because it must evaluate it's arguments lazily, and using macros is the only way to do it. But try to apply `and` to the list of values (I know, that it's a job for a function `every?`, but how w

How to simplify cond statements

2010-10-28 Thread andrei
Hi, I have a code similar to this: (def pairs (list [1 :a] [2 :b] [3 :c])) ... (loop [ps pairs, ret {}] (cond (empty? ps) ret (some-test (first (first ps))) (recur (rest ps) (add-to- result ret (first (first ps :true (recur (rest ps) (do-smth-else ret (first (fir

Re: Fastest way to generate comma-separated list

2010-10-28 Thread andrei
> Are you looking for pr-str? > > user> (pr-str "foo") > "\"foo\"" Yeah, that's exactly what I tried to implement with my `pr-to-str`, thank you. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

Re: Fastest way to generate comma-separated list

2010-10-28 Thread andrei
> Does this help? > > user> (use 'clojure.string) > nil > user> (join "," (range 10)) > "0,1,2,3,4,5,6,7,8,9" It still doesn't work for the list of strings. But thanks for reminding about it. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: Fastest way to generate comma-separated list

2010-10-27 Thread andrei
I was seeking `interpose` function, thanks. But it still doesn't work for strings - they are not wrapped by "\"\. E.g. (apply str (interpose ", " (list 1 2 3 4 5))) ==> "1, 2, 3, 4, 5" and (apply str (interpose ", " (list "1" "2" "3" "4" "5"))) ==> "1, 2, 3, 4, 5" The problem is that applying

Fastest way to generate comma-separated list

2010-10-27 Thread andrei
Hi all, I work with a database and need a function, that will convert Clojure sequence to a string with a comma-separated elements. E.g., (comma-separated (list 1 2 3 4 5)) ==> "1, 2, 3, 4, 5" It must work with any data type - ints, strings, other lists, etc. E.g. for a list of strings it mu

Re: Strange behavior of PersistentTreeMap

2010-10-23 Thread andrei
Huh! I checked several times to pass to recur replaced string, but didn't noticed that I'm passing wrong string to .replace itself. Thank you! On Oct 23, 10:12 pm, Chris Perkins wrote: > On Oct 23, 2:10 pm, andrei wrote: > > > I modified procedure a bit to see interim re

Re: Strange behavior of PersistentTreeMap

2010-10-23 Thread andrei
I modified procedure a bit to see interim results, and it's output confused me even more. (defn replace-map "Replaces substrings in s from (keys m) by (vals m). " [s m] (loop [cur-str s, ks (keys m)] (if (empty? ks) cur-str (let [replaced (.replace s (first ks) (m (first ks))

Strange behavior of PersistentTreeMap

2010-10-22 Thread andrei
My purpose is to write function for replacing multiple substrings in a string. Here's my approach: (defn replace-map "Replaces substrings in s from (keys m) by (vals m). " [s m] (loop [cur-str s, rps m] (if (empty? rps) cur-str (recur (.replace s (first (first rps)) (second (

Re: Transient maps do not work?

2010-10-21 Thread andrei
Oh, I didn't understand this line before. Now I see my error, thank you. On Oct 21, 6:27 pm, Jürgen Hötzel wrote: > 2010/10/21 andrei : > > > > > > > (defn test [] > >  (let [transient-map (transient {})] > >      (doseq [i (range 100)] &g

Transient maps do not work?

2010-10-21 Thread andrei
(defn test [] (let [transient-map (transient {})] (doseq [i (range 100)] (conj! transient-map {i (str i)} )) (persistent! transient-map))) I expect that it will produce: { 0 "0", 1 "1", 2 "2", ..., 99 "99"} but it gives only {0 "0", 1 "1", ..., 7 "7"} i.e. only first 8

Re: Override print-method of struct

2010-10-14 Thread andrei
> Maybe you could use a parent map. > You have a normal tree, and then you have a map where > you can get the parent for a given node. I don't know if this > will be too slow for your problem - it's just an idea. I haven't thought about it, thank you. I'm going to try different options and decid

Re: Override print-method of struct

2010-10-14 Thread andrei
ints or using alters.  The thunk would be created as > part of the process. > > Mark > > On Oct 13, 4:21 pm, andrei wrote: > > > That works, thanks! > > > Yeah, I understand that it is not the best data structure to use. The > > task is to create a tree, a

Re: Override print-method of struct

2010-10-13 Thread andrei
ess that you're building a tree made of mixins of maps and refs to maps > ... and indeed this should bell some rings in your head if you haven't > already carefully balanced alternative choices ... > > 2010/10/13 andrei > > > How can I override print-method for a map

Override print-method of struct

2010-10-13 Thread andrei
How can I override print-method for a map, defined with defstruct? I have to create object hierarchy: one map is a parent for another, i.e. it holds link to a child, and another is a child for the first one, i.e. holds link to a parent. When I try to print it, I get StackOverflowError since printe