It's a bit hard (at least for me) to see what you're actually trying to do here that would precent a direct translation of your snippet to Clojure's for. Could you perhaps post a complete, self-contained code example in Scala?
On Thursday, 26 November 2015, Torsten Uhlmann <torsten.uhlm...@gmail.com> wrote: > Hi Rastko, > > One way of doing that would be to use the mlet macro from the Cats > library: http://funcool.github.io/cats/latest/#mlet > > Also, there are several if-lets or when-lets out there that allow multiple > bindings, I used one from https://github.com/ptaoussanis/encore > > I use Scala's for most of the time when there are Options in the mix that > may or may not hold a value. > > For binding to generators, Clojures for might be a better fit? > https://clojuredocs.org/clojure.core/for > > Would that help you? > > Torsten. > > PS: I'm learning Clojure myself with Scala and Java background. > > On Thursday, November 26, 2015 at 12:12:01 PM UTC+1, Rastko Soskic wrote: >> >> Hi, >> I am aware of philosophical differences of Scala and Clojure >> but functional programming should be a pretty common ground :) >> Thus I need help, I am trying to mimic Scala's for comprehension in >> Clojure. >> >> Hopefully someone will be able to aid me with the following (perhaps more >> familiar with Scala): >> >> Scala for comprehension is errr how to say "de-sugared" to series >> of map and flatMap calls... thus, it is possible to use plain functions >> in for-comprehension >> like: >> *val *ns: Conv[List[Int]] = *for *{ // Conv is just alias for functions >> of type B => (B, A) >> x <- int // int is function again of type Conv >> y <- int >> xs <- ints(x) // this is just sequence of numbers >> } *yield *xs.map(_ * y) >> >> I don't need all the nuts and bolts, just some guideline for achieving >> something similar >> in Clojure. >> >> I am not lazy :) I've already eagerly researched a bit and got to this: Scala >> for-comprehension to Clojure >> <http://stackoverflow.com/questions/25655132/how-to-convert-this-map-flatmap-into-a-for-comprehension-in-clojure> >> >> But as you can see that is not really about having kind of generator >> function which is wrapped into flatMap >> call. Perhaps this is not in Clojure's spirit at all, perhaps there is >> some Clojure idiom to achieve something similar. >> >> Any tip, suggestion, critic is welcome and appreciated. >> >> If someone is wondering how in the world I came up to this, I am doing >> some f-p exercises which I've got Scala solution for >> however I am not very interested in Scala and I am doing Clojure so I >> just need to grasp concepts... >> >> Thanks in advance... >> > -- > 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 > <javascript:_e(%7B%7D,'cvml','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 > <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@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 > <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');>. > For more options, visit https://groups.google.com/d/optout. > -- 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.