side-effect only function with map-like syntax (again)

2014-01-27 Thread Mars0i
Back in 2007 (https://groups.google.com/forum/#!searchin/clojure/mapc/clojure/x0PDu_D6mP0/3A7CZe-ZDWAJ), Henk Boom raised the possibility of including in Clojure a function with syntax like map, but semantics more like Common Lisp's mapc (or Scheme's for-each, I believe). It works just like C

Re: side-effect only function with map-like syntax (again)

2014-01-27 Thread Jan Herich
How about doseq ? Dňa utorok, 28. januára 2014 5:28:04 UTC+1 Mars0i napísal(-a): > > Back in 2007 ( > https://groups.google.com/forum/#!searchin/clojure/mapc/clojure/x0PDu_D6mP0/3A7CZe-ZDWAJ), > > Henk Boom raised the possibility of inclu

Re: side-effect only function with map-like syntax (again)

2014-01-28 Thread Mars0i
On Tuesday, January 28, 2014 1:17:58 AM UTC-6, Jan Herich wrote: > > How about doseq ? > doseq can do the same work, and can do more, but it requires one to specify variable names to be used in each application of the function. For some p

Re: side-effect only function with map-like syntax (again)

2014-01-28 Thread Stefan Kamphausen
Does wrapping your map expression in a dorun do what you want? Stefan -- -- 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

Re: side-effect only function with map-like syntax (again)

2014-01-28 Thread Jozef Wagner
If side effects is all what is needed, I would skip the creation of lazy seqs and do it with reduce: user=> (defn mapc [f coll] (reduce (fn [_ v] (f v)) nil coll)) #'user/mapc user=> (mapc println [1 2 3]) 1 2 3 nil JW On Tue, Jan 28, 2014 at 2:29 PM, Stefan Kamphausen wrote: > Does wrapping y

Re: side-effect only function with map-like syntax (again)

2014-01-28 Thread Mars0i
On Tuesday, January 28, 2014 7:29:06 AM UTC-6, Stefan Kamphausen wrote: > > Does wrapping your map expression in a dorun do what you want? > Yes, it does. But that's more verbose, and as Jozef Wagner notes, it creates seqs unnecessarily. I like Jozef's solution. However, I think a proper defin

Re: side-effect only function with map-like syntax (again)

2014-01-28 Thread Jozef Wagner
Regarding names, I would not place a bang after it (!), as there is nothing in that function itself that forbids its use inside transactions. Functions which primary purpose is to produce side effects tend to begin with 'do', so my suggestion is to name it 'domap'. I am however still not convi

Re: side-effect only function with map-like syntax (again)

2014-01-28 Thread Mars0i
Jozef, Thanks--good advice about names. Well, I don't know whether useful is the right word. domap (nee mapc) obviously wouldn't add any functionality. (Neither does 'map', I suppose, since we have 'for'.) I seem to be unusual in my affection for this construct outside of purely functiona