Now I am on the REPL, and the solution is straightforward:

(foldmap op nil println [1 2 3] [4 5 6])

gives:

1 4
2 5
3 6
nil

The first function is a folding function. In this case we can use op, a 
monoid operation. Since nil is also a monoid, everything will be folded to 
nil. The second part is a function that maps inputs to the monoid that we 
need (nil in this case). println does just this, and does the side effect 
that you asked for. No extra sequence building involved, and we do not need 
to write extra functions. 

On Saturday, September 24, 2016 at 2:42:16 AM UTC+2, Mars0i wrote:
>
> Thanks everyone--I'm very much appreciating the discussion, though I'm not 
> sure I follow every point.  
>
> Dragan, thank you very much for suggesting (and writing) foldmap.  Very 
> nice.  I certainly don't mind using a library, though I still think there 
> ought to be something like what I've described in the language core.
>
> Francis, thanks for separating out the different types of intermediate 
> collections.  I'm not entirely clear on type 1.  It sounds like those are 
> just collections that are already there before processing them.  Or are you 
> saying that Clojure has to convert them to a seq as such?  Why would doseq 
> have to do that, for example?
>
> It's an understatement to say that my understanding of monads, monoids, 
> etc. is weak.   Haven't used Haskell in years, and I never understood 
> monads, etc..  They seem trivial or/and or deeply mysterious.  One day I'll 
> have to sit down and figure it out.  For foldmap, I don't understand what 
> the first function argument to foldmap is supposed to do, but it's easy 
> enough to put something there that does nothing.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to