Re: [ANN] cpython bindings for clojure

2019-06-08 Thread Mattias Arro
This is beyond cool. Thank you so much for putting this together! -- 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 you

Re: [ANN] cpython bindings for clojure

2019-06-05 Thread Daniel Carleton
Excellent! I'd just been considering with trepidation trying to use jython for something when your message appeared. On Wed, Jun 5, 2019, 5:40 PM Alan Moore wrote: > Awesome! > > Alan > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post

[ANN] cpython bindings for clojure

2019-06-05 Thread Alan Moore
Awesome! Alan -- 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

Re: [ANN] cpython bindings for clojure

2019-06-05 Thread Rick Mangi
t;> best possible libraries for any particular problem on the planet, I took >>> the last month and built out raw cpython (libpython3.X) bindings based on >>> JNA. >>> >>> So, today after cleaning things up just a little bit I decided it was >>> time to

Re: [ANN] cpython bindings for clojure

2019-06-05 Thread John Newman
; So, in the spirit of building bridges and providing clojure with the best >> possible libraries for any particular problem on the planet, I took the >> last month and built out raw cpython (libpython3.X) bindings based on JNA. >> >> So, today after cleaning things up just a

Re: [ANN] cpython bindings for clojure

2019-06-05 Thread Jonah Benton
m on the planet, I took the > last month and built out raw cpython (libpython3.X) bindings based on JNA. > > So, today after cleaning things up just a little bit I decided it was time > to announce libpython-clj. My hope is that there are enough clojuian > pythonistas that we can tak

[ANN] cpython bindings for clojure

2019-06-05 Thread Chris Nuernberger
libraries being the problem. So, in the spirit of building bridges and providing clojure with the best possible libraries for any particular problem on the planet, I took the last month and built out raw cpython (libpython3.X) bindings based on JNA. So, today after cleaning things up just a little bit

Re: [ANN] Opencv bindings for clojure

2018-10-30 Thread Nicolas Modrzyk
Hi Chris, Great work! Sorry to jump in. I had already been working on an auto-generated wrapper directly for opencv. (not javacv though) It's called origami and is on github: https://github.com/hellonico/origami/tree/master I just ported origami to OpenCV4-beta. Maybe there is some work or e

[ANN] Opencv bindings for clojure

2018-10-29 Thread chris
http://techascent.com/blog/opencv-love.html Enjoy :-). If we would have had this earlier then a lot of our projects would have taken considerably less time. Also note at the end where we do some vector math in unsigned byte space using the opencv image as the backing store. Chris -- You

Re: How to try/catch Let bindings?

2017-10-08 Thread Gary Verhaegen
pecific use-case, you can probably, as an intermediate solution, define a fairly simple macro that would get you almost all you want, something like: (defmacro mlet [bindings & body] (if (seq bindings) (let [[b expr & r] bindings] `(try (let [~b ~expr] (ml

Re: How to try/catch Let bindings?

2017-10-07 Thread Nathan Fisher
t; c (do-c . a . b)] > (log/info "Success" {:a a >:b b >:c c}) > c) > > Now, say each steps could possibly throw an exception. So you want to > try/catch the let bindings: > > (try > (let [a (do-a

Re: How to try/catch Let bindings?

2017-10-07 Thread Fabrizio Ferrai
Now that bertschi mentioned Haskell and side-effects, I noticed that the problem we have here totally looks like a monad: we have several steps of side-effecting computation, and each of them can fail, and when this happens you want to handle the failure while keeping the previous bindings. Now

Re: How to try/catch Let bindings?

2017-10-06 Thread 'bertschi' via Clojure
der ... just ask yourself what value the variable c should be bound to if an exception is thrown by doB. Both suggested solutions seem to be reasonable. While try-let ignores all bindings when an error occurs (check with macroexpand), the interceptor chain probably can see all bindings e

Re: How to try/catch Let bindings?

2017-10-02 Thread Didier
> Even in an impure language such as Common Lisp we frown on such LET forms True, but as far as I know, in Common Lisp, the condition handler is always in scope of where the error happened, so I wouldn't face this problem. I also struggle to split this up into functions without making it even mo

Re: How to try/catch Let bindings?

2017-10-02 Thread hiskennyness
en in an impure language such as Common Lisp we frown on such LET forms. I believe it was Lisp legend Paul Graham who suggested we imagine a tax on LET. Sometimes while sorting out something complex I do solve it in a series of LET bindings, but once I understand what I am about I am able to ad

Re: How to try/catch Let bindings?

2017-10-02 Thread Luke Burton
> On Oct 1, 2017, at 9:21 PM, Didier wrote: > > I can't emphasize enough the utility of the interceptor chain pattern, as > employed heavily in pedestal. > > Interesting... Its almost like a workflow framework, but for simpler in code > workflows. I'm reluctant to have a dependency on pedest

Re: How to try/catch Let bindings?

2017-10-02 Thread Duncan McGreggor
Didier, I've done something similar a few times just using core.async -- no extra deps required ;-) d On 1 October 2017 at 23:21, Didier wrote: > I can't emphasize enough the utility of the interceptor chain pattern, as >> employed heavily in pedestal. >> > > Interesting... Its almost like a w

Re: How to try/catch Let bindings?

2017-10-02 Thread Daniel Compton
Hi Didier The interceptor pattern is pretty tiny, certainly small enough to copy from project to project if you wanted. You can see re-frame's implementation here: https://github.com/Day8/re-frame/blob/master/src/re_frame/interceptor.cljc which is only around 100 SLOC. That doesn't handle exceptio

Re: How to try/catch Let bindings?

2017-10-01 Thread Didier
> > I can't emphasize enough the utility of the interceptor chain pattern, as > employed heavily in pedestal. > Interesting... Its almost like a workflow framework, but for simpler in code workflows. I'm reluctant to have a dependency on pedestal just for this though. On Sunday, 1 October 201

Re: How to try/catch Let bindings?

2017-10-01 Thread Luke Burton
> On Sep 30, 2017, at 3:14 PM, Didier wrote: > > Is there another way to execute a set of complex steps which does not rely on > let and can be try/catched in the manner I describe? I can't emphasize enough the utility of the interceptor chain pattern, as employed heavily in pedestal. I use

Re: How to try/catch Let bindings?

2017-10-01 Thread Didier
I've seen this, I was still curious if the reason I was facing the issue was that let is simply the wrong tool for my use case or not. If let is the correct tool, I would propose that clojure.core should had a try/catch where the catch is in scope of the try. I feel the reason this is contrived

How to try/catch Let bindings?

2017-09-30 Thread Marcus Magnusson
I've used try-let (link below) for this, it's worked great! https://github.com/rufoa/try-let -- 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

How to try/catch Let bindings?

2017-09-30 Thread Didier
(do-b . a . .) c (do-c . a . b)] (log/info "Success" {:a a :b b :c c}) c) Now, say each steps could possibly throw an exception. So you want to try/catch the let bindings: (try (let [a (do-a ...) b (do-b . a . .)

[ANN] martian 0.1.5 - now with bindings for re-frame

2017-08-15 Thread Oliver Hine
Hi everyone, I have just released martian 0.1.5 which includes a new library called martian-re-frame . Martian provides an abstraction allowing you to describe the HTTP endpoints that

Re: Modern opengl bindings in clojure

2017-07-15 Thread lispwisp
No the docs aren't out of sync, what you are seeing are gl's thousands of constant declarations. They are used as arguments to various gl functions, and I expose them as vars in the library. If you scroll down to the very bottom you will see the implementation, which because of the design choice

Re: Modern opengl bindings in clojure

2017-07-14 Thread Timothy Baldridge
Are the docs out of sync? Because the README talks about immutable APIs and seq to array conversions, but the library itself is just a renaming wrapper mapping stuff like GL/GLVertex to gl-vertex. I don't understand how that makes the API "modern". Unless that part isn't written yet. Timothy On F

Re: Modern opengl bindings in clojure

2017-07-14 Thread Kevin Baldor
I see that it's uploaded to clojars so it might be a bit late to ask, but what is the convention on naming libraries like this? I'm used to seeing something like clj-gl for libraries that provide a Clojure wrapper around an existing library. Regardless, this is awesome and I hope to play with it

Modern opengl bindings in clojure

2017-07-14 Thread lispwisp
This library is a work in progress, but is in a usable state and there is unlikely to be any breaking changes to the api: https://github.com/bcbradle/gl -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goo

Re: recursive bindings not available in let form?

2016-12-04 Thread Timothy Baldridge
Let bindings map pretty much directly to Java style local variables: (let [x 42] (let [x 3] (+ x 3)) Becomes something like this when compiled to byte code: x_1 = 42 x_2 = 3 return x_2 +3 So let bindings with the same names are kept separate via modifying the stored name in the byte code

Re: recursive bindings not available in let form?

2016-12-03 Thread Paul Gowder
That's a really neat post. Thank you for writing it! How do bindings created by let fit into that picture? > The question of how vars work comes up enough that I recently wrote a blog > post on the subject. Maybe it will be useful to you. > http://blog.cognitect.com/blog/2016

Re: recursive bindings not available in let form?

2016-12-03 Thread Timothy Baldridge
The question of how vars work comes up enough that I recently wrote a blog post on the subject. Maybe it will be useful to you. http://blog.cognitect.com/blog/2016/9/15/works-on-my-machine-understanding-var-bindings-and-roots Timothy On Fri, Dec 2, 2016 at 2:44 PM Paul Gowder wrote: > Tha

Re: recursive bindings not available in let form?

2016-12-02 Thread Mark Engelberg
Your "y" could also be "fib". You are permitted to use the same name inside the fn. On Fri, Dec 2, 2016 at 12:59 PM, Walter van der Laan < waltervanderl...@gmail.com> wrote: > AFAIK there are two options. > > You can add a symbol after fn: > > (let [fib (fn y [x] > (cond >

Re: recursive bindings not available in let form?

2016-12-02 Thread Paul Gowder
Thanks Bobby, Francis, Walter! Now trying to wrap my head around the idea of def as a ref... On Friday, December 2, 2016 at 2:57:13 PM UTC-6, Francis Avila wrote: > > Let bindings are immutable bindings, not refs. They must act as if their > value could be substituted at the moment

Re: recursive bindings not available in let form?

2016-12-02 Thread Walter van der Laan
AFAIK there are two options. You can add a symbol after fn: (let [fib (fn y [x] (cond (< x 2) x :else (+ (y (- x 2)) (y (- x 1)] (fib 5)) Or, as Bobby already suggested, you can use letfn: (letfn [(fib [x] (cond (<

recursive bindings not available in let form?

2016-12-02 Thread Francis Avila
Let bindings are immutable bindings, not refs. They must act as if their value could be substituted at the moment they are referenced. Def (i.e. a ref) is a mutable container whose contents is examined when it is used (not when referenced), which is why your second example works. Why doesn&#

Re: recursive bindings not available in let form?

2016-12-02 Thread Bobby Eickhoff
Note that letfn does allow recursive bindings, though I couldn't comment as to the implementation details. On Friday, December 2, 2016 at 3:01:13 PM UTC-5, Paul Gowder wrote: > > Hi clojure-world, > > I think maybe this is actually related to the complexities of binding &g

recursive bindings not available in let form?

2016-12-02 Thread Paul Gowder
Hi clojure-world, I think maybe this is actually related to the complexities of binding referenced in the previous thread (https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!topic/clojure/zBXsrqTN2xs)... maybe? But it would be amazing if some wise person would help explain.

if-let and friends with multiple bindings

2015-11-09 Thread Karl Mikkelsen
If you have ever wished if-let and friends would allow multiple bindings wish no more. Check out... https://github.com/LockedOn/if-let -Karl -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: Let bindings and immutability

2015-02-12 Thread Luc Préfontaine
Think about values first, symbols after. Symbols are accessory, not values, values are the only things that exist at runtime. Symbols are only there for you poor human (I include myself in this statement) to grasp roughly what is going on by tracking intermediate values with names. The names y

Re: Let bindings and immutability

2015-02-11 Thread James Reeves
On 12 February 2015 at 02:06, gvim wrote: > > That explains it but I think Clojure's syntax is misleading here. Without > knowledge of this magic the mind doesn't readily translate: > > (let [x 1 > x (inc x) > x (inc x) > x (inc x)] >x) > > into: > > (let [x 1] >

Re: Let bindings and immutability

2015-02-11 Thread Herwig Hochleitner
2015-02-12 3:06 GMT+01:00 gvim : > > That explains it but I think Clojure's syntax is misleading here. Without > knowledge of this magic the mind doesn't readily translate: > > In some other lisps, clojure's let is called let* for this reason. Their let binds only in parallel, similar to clojure's

Re: Let bindings and immutability

2015-02-11 Thread Herwig Hochleitner
I think that, from a user perspective, the important difference from mutation to shadowing is, that outer x is available even in the inner context, if captured by a closure. Likewise, a second thread, that runs an outer closure, would see the original x. Observe: (let [x :outer f (fn [] x)

Re: Let bindings and immutability

2015-02-11 Thread gvim
On 12/02/2015 01:53, Ben Wolfson wrote: The multiple-binding form of let can be recursively transformed into nested lets: (let [name1 value1 name2 value2 ... name value] body) > (let [name1 value1] (let [name2 value2] ... (let [name value] body))) All you're doing with your let form is sha

Re: Let bindings and immutability

2015-02-11 Thread Ambrose Bonnaire-Sergeant
Local bindings are immutable. Your example demonstrates lexical shadowing of bindings. This is an equivalent program semantically. (let [x 1 x_1 (inc x) x_2 (inc x_1) x_3 (inc x_2)] x_3) By the rules of lexical scoping, you cannot access the first `x` but it is never

Re: Let bindings and immutability

2015-02-11 Thread Justin Smith
(let [x 0 f #(println x) x 1 g #(println x) x 2] (f) (g) x) there is no mutation of x, only scope shadowing hiding the other binding. Most functional languages (all that I know) allow shadowing. -- You received this message because you are subscribed to the Goo

Re: Let bindings and immutability

2015-02-11 Thread Ben Wolfson
The multiple-binding form of let can be recursively transformed into nested lets: (let [name1 value1 name2 value2 ... name value] body) > (let [name1 value1] (let [name2 value2] ... (let [name value] body))) All you're doing with your let form is shadowing the name; there's no mutation. If y

Re: Let bindings and immutability

2015-02-11 Thread gvim
On 12/02/2015 01:44, Laurens Van Houtven wrote: Hi, You’re confusing mutation with single assignment. You’re not mutating anything: 1 is still 1, 2 is still 2; you’re just assigning the same name to different numbers. The numbers themselves are immutable. It's x that bothers me, not the val

Re: Let bindings and immutability

2015-02-11 Thread Laurens Van Houtven
Hi, > On Feb 11, 2015, at 5:42 PM, gvim wrote: > > Why is this possible in a language based on immutability: > > (let [x 1 >x (inc x) >x (inc x) >x (inc x)] > x) > > ;;=> 4 > > Maybe under the hood (ie. memory registers/pointers etc.) this isn't strictly > mutation

Let bindings and immutability

2015-02-11 Thread gvim
Why is this possible in a language based on immutability: (let [x 1 x (inc x) x (inc x) x (inc x)] x) ;;=> 4 Maybe under the hood (ie. memory registers/pointers etc.) this isn't strictly mutation but as a relative newcomer to Clojure I find it goes against the grain

Re: Wouldn't it be nice if if-let allowed more bindings?

2014-11-27 Thread Fluid Dynamics
On Wednesday, November 26, 2014 10:06:41 PM UTC-5, Michael Blume wrote: > > Instead of the deshadowing logic, why not > > (defn if-and-let* > [bindings then-clause else-fn-name] > (if (empty? bindings) > then-clause > `(if-let ~(vec (take 2 bindings)) >

Re: Wouldn't it be nice if if-let allowed more bindings?

2014-11-26 Thread Sam Ritchie
You've discovered the error (or Either) monad! https://brehaut.net/blog/2011/error_monads Michael Blume <mailto:blume.m...@gmail.com> November 26, 2014 at 8:06 PM Instead of the deshadowing logic, why not (defn if-and-let* [bindings then-clause else-fn-name] (if (empty? binding

Re: Wouldn't it be nice if if-let allowed more bindings?

2014-11-26 Thread Michael Blume
Instead of the deshadowing logic, why not (defn if-and-let* [bindings then-clause else-fn-name] (if (empty? bindings) then-clause `(if-let ~(vec (take 2 bindings)) ~(if-and-let* (drop 2 bindings) then-clause else-fn-name) (~else-fn-name (defmacro if-and-let

Wouldn't it be nice if if-let allowed more bindings?

2014-11-26 Thread Fluid Dynamics
Wouldn't it be nice if if-let allowed more bindings? Try this, which I hereby dedicate into the public domain so that anyone may use it freely in their code without restrictions: (defn if-and-let* [bindings then-clause else-clause deshadower] (if (empty? bindings) then-clause

[ANN] jnanomsg 0.3.1 - Clojure and Java bindings for nanomsg.

2014-02-09 Thread Andrey Antukh
Clojure and Java bindings for nanomsg[1] (build on top of JNA) Changes: - New: experimental async api support for java bindings. - New: experimental core.async support for all sockets. - New: experimental core.async channels implementation (only for pipeline sockets) - Fixes: removed hardcoded

Re: let bindings

2014-01-21 Thread Andy Smith
Excellent post, thank you for that. -- -- 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 unsubscr

Re: let bindings

2014-01-20 Thread John Mastro
> If there's another reason then I'm hoping someone will correct me, but I > can't think of any other reasons at the moment. Since Clojure doesn't do tail call elimination implementing let atop fn would also use up stack. I believe many or all Schemes (which are required by the spec to eliminat

Re: let bindings

2014-01-20 Thread Kevin Downey
On 1/20/14, 12:38 PM, Andy Smith wrote: > Hi, > > (let bindings form) is a special form. As I understand it, let can be > reformulated in terms of functions e.g. > > (let [x 2] (* x 20)) equivalent to ((fn [x] (* x 20)) 2) > (let [x 3 y (* x x)] (- y x)) equivalent to ((f

Re: let bindings

2014-01-20 Thread Carlo Zancanaro
Hey Andy! On Mon, Jan 20, 2014 at 12:38:23PM -0800, Andy Smith wrote: > So if we can always reformulate in this was, why cant let be implemented as > a macro rather than a special form? It can. Quite easily, in fact: (defmacro my-let [bindings & body] (if (empty? bindings) `

Re: let bindings

2014-01-20 Thread Jozef Wagner
> Hi, > > (let bindings form) is a special form. As I understand it, let can be > reformulated in terms of functions e.g. > > (let [x 2] (* x 20)) equivalent to ((fn [x] (* x 20)) 2) > (let [x 3 y (* x x)] (- y x)) equivalent to ((fn [x] ((fn [x y] (- y x)) x > (* x x)

Re: let bindings

2014-01-20 Thread Andy Smith
typo : was=way -- -- 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,

let bindings

2014-01-20 Thread Andy Smith
Hi, (let bindings form) is a special form. As I understand it, let can be reformulated in terms of functions e.g. (let [x 2] (* x 20)) equivalent to ((fn [x] (* x 20)) 2) (let [x 3 y (* x x)] (- y x)) equivalent to ((fn [x] ((fn [x y] (- y x)) x (* x x))) 3) So if we can always reformulate

Re: [ANN] jnanomsg 0.2.0 - Clojure and Java bindings for nanomsg.

2014-01-07 Thread am
Andrey, Thank-you for the lib and adding the pipeline protocol. Cheers. Amar On Tuesday, January 7, 2014 5:10:17 PM UTC-5, Andrey Antukh wrote: > > Clojure and Java bindings for nanomsg[1] (build on top of JNA) > > nanomsg[1] is a socket library that provides common communication

[ANN] jnanomsg 0.2.0 - Clojure and Java bindings for nanomsg.

2014-01-07 Thread Andrey Antukh
Clojure and Java bindings for nanomsg[1] (build on top of JNA) nanomsg[1] is a socket library that provides common communication patterns. It aims to make the networking layer fast, scalable, and easy to use. This is a first announcement of this library with 0.2 version! 0.1 version was just a

Re: let bindings in tree-seq funciton

2013-09-05 Thread Cedric Greevey
ither: * Short; * Long let bindings, short body; * Mid-size; * Mostly a (loop ...); or * Mostly a body that mutates stuff, likely a big (doto ...) or (dosync ...) or a series of send-off, swap!, etc. The last and some of the others being not pure, so usually at the periphery of the system. Controller

Re: let bindings in tree-seq funciton

2013-09-05 Thread Kuba Roth
Thanks, very interesting point. It's a shame this is not available in the clojure docs - very useful for newcomers as me. Is it fair to say that let bindings is good/recomended to put all the code and the main body is used primarily for returning results of the function? Cheers,

Re: let bindings in tree-seq funciton

2013-09-05 Thread Cedric Greevey
More likely it has to do with simply naming many of the intermediate results in a calculation. That often results in long let bindings with short let bodies. I've written many a function that's basically (defn foo [x] (let [stuff more stuff yet more stuff r

let bindings in tree-seq funciton

2013-09-04 Thread Kuba Roth
I'm currently working with tree-seq function from clojure.core and there is one thing I'm struggling to understand... Could you please explain why pretty much all of the body of the function sits within 'let binding' and not in the 'let body' where only (walk root) is placed? Has it something to

[ANN] clj-leveldb, idiomatic LevelDB bindings from Factual

2013-09-03 Thread Zach Tellman
In the first of what I hope will be many annoucements, we're open sourcing a library we've found useful at Factual: https://github.com/Factual/clj-leveldb. This is just a simple wrapper around LevelDB, which is an in-process persistent k/v store from Google. If anyone has questions, I'm happy

Re: core.async: loop bindings can't see prior brindings

2013-08-08 Thread Kemar
ug 8, 2013 at 9:22 AM, David Nolen > > wrote: > >> You can report issues here: http://dev.clojure.org/jira/browse/ASYNC >> >> >> >> On Thu, Aug 8, 2013 at 7:02 AM, Kemar >wrote: >> >>> Hi there, >>> >>> it seems that loop

Re: core.async: loop bindings can't see prior brindings

2013-08-08 Thread Timothy Baldridge
wrote: > >> Hi there, >> >> it seems that loop bindings cant's see prior bindings made in >> the same loop when the loop is in a go block: >> >> (require '[clojure.core.async :refer [go]]) >>> (go (loop [x 41 y (inc x)] (println y))) >>

Re: core.async: loop bindings can't see prior brindings

2013-08-08 Thread David Nolen
You can report issues here: http://dev.clojure.org/jira/browse/ASYNC On Thu, Aug 8, 2013 at 7:02 AM, Kemar wrote: > Hi there, > > it seems that loop bindings cant's see prior bindings made in > the same loop when the loop is in a go block: > > (require '[clojure.cor

core.async: loop bindings can't see prior brindings

2013-08-08 Thread Kemar
Hi there, it seems that loop bindings cant's see prior bindings made in the same loop when the loop is in a go block: (require '[clojure.core.async :refer [go]]) > (go (loop [x 41 y (inc x)] (println y))) > Rather than printing 42, it either complains that x can't be res

Re: core.async: faulty rebinding of loop-bindings in go blocks

2013-08-03 Thread Kemar
It appears to be working, awesome! Thanks! Cheers, Kevin Am Samstag, 3. August 2013 21:05:57 UTC+2 schrieb Ghadi Shayban: > > Fixed -- should make it to maven within an hour. > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this grou

Re: core.async: faulty rebinding of loop-bindings in go blocks

2013-08-03 Thread Ghadi Shayban
M UTC-4, Kemar wrote: >> >> There seems to be an issue with the rebinding of loop-bindings using >> loop/recur in go blocks, >> specifically when you are just changing the order of the original >> bindings in a recur call. >> >> Take this snippet for example:

Re: core.async: faulty rebinding of loop-bindings in go blocks

2013-08-01 Thread Ghadi Shayban
It's a nasty bug, seems like a local symbol scope issue. I will take a look at it. Thanks for the report. On Thursday, August 1, 2013 6:05:59 AM UTC-4, Kemar wrote: > > There seems to be an issue with the rebinding of loop-bindings using > loop/recur in go blocks, > specific

core.async: faulty rebinding of loop-bindings in go blocks

2013-08-01 Thread Kemar
There seems to be an issue with the rebinding of loop-bindings using loop/recur in go blocks, specifically when you are just changing the order of the original bindings in a recur call. Take this snippet for example: (require '[clojure.core.async :refer [go timeout]]) > (go (loop [

[ANN] clj-bigml - Clojure bindings for BigML's machine learning API

2013-01-17 Thread Adam Ashenfelter
clj-bigml is a Clojure library for interacting with BigML's machine learning API . As of now, BigML offers decision tree models (and their ensembles like random decision forests) for supervised learning. Wi

Re: list of special forms that introduce bindings?

2012-11-08 Thread Herwig Hochleitner
I'm not aware of such a list, but there aren't that many special forms. Other than the mentioned fn*, let* and catch, you have loop* and def. def doesn't create a lexical binding like the others, but creates its var before evaluating its init-expr. -- You received this message because you are su

list of special forms that introduce bindings?

2012-11-07 Thread Ben Wolfson
Is there a list of the special forms that can introduce names (fn*, let*, catch ...)? (keys clojure.lang.Compiler/specials) gives a list of all the special forms, but not all of them introduce new bindings. -- Ben Wolfson "Human kind has used its intelligence to vary the flavour of drinks,

Re: dynamically generated let bindings

2011-07-30 Thread Ken Wesson
On Sat, Jul 30, 2011 at 9:07 PM, Alan Malloy wrote: > (get :foo argmap__5673__auto 42) is the right way to solve this > problem. Is another way to solve it, yes, and a good one. > Or if, as in the current example, you want to destructure a map with > lots of defaults, simply: > > (let [{:keys [f

Re: dynamically generated let bindings

2011-07-30 Thread Alan Malloy
On Jul 29, 2:02 pm, Ken Wesson wrote: > (fn [& args] >   (let [argmap__5673__auto (#'some-ns/parse-args args) >         foo (or (:foo argmap__5673__auto) 42) >         bar (or (:bar argmap__5673__auto) nil) >         ...] >     (body goes here))) > where you define a private parse-args function in

Re: dynamically generated let bindings

2011-07-30 Thread Ken Wesson
On Sat, Jul 30, 2011 at 7:29 AM, Sam Aaron wrote: >> (fn [& args] >>  (let [foo (some logic goes here) >>        bar (some logic goes here) >>        ...] >>    (body goes here))) > > I just finished implementing a solution and it looks exactly like this. > You're absolutely right - this is preci

Re: dynamically generated let bindings

2011-07-30 Thread Sam Aaron
Hi Ken, On 29 Jul 2011, at 22:02, Ken Wesson wrote: >> P.S. Thanks everyone for your help so far. My brain is overheating but I am >> learning a lot. > > You're welcome. > > To do what you're proposing you will probably need the emitted > function to look like: > > (fn [& args] > (let [foo (s

Re: dynamically generated let bindings

2011-07-29 Thread Ken Wesson
> P.S. Thanks everyone for your help so far. My brain is overheating but I am > learning a lot. You're welcome. To do what you're proposing you will probably need the emitted function to look like: (fn [& args] (let [foo (some logic goes here) bar (some logic goes here) ...]

Re: dynamically generated let bindings

2011-07-29 Thread Sam Aaron
amp; ~args] (let ~(binding-vec args) ~@forms ((magic-fn (+ size 10)) 1 2) ;=> Unable to resolve symbol: size in this context > > (defmacro with-arg-params [bindings & body] > (let [bindings (apply array-map bindings)] >`(fn > ~@(for [i (range (inc

Re: dynamically generated let bindings

2011-07-29 Thread Ken Wesson
z) > > a would now be bound to a fn which I could call: > > (yo 1 2 3) ;=> 6 > > I could also call it with fewer args than expected: > > (yo 1 2) ;=> 5 > > this works because bad has a default of 2. (defmacro with-arg-params [bindings & body] (let [bin

Re: dynamically generated let bindings

2011-07-29 Thread Sam Aaron
On 29 Jul 2011, at 12:11, Ken Wesson wrote: > > Why not just (vec (interleave names (take (count names) (repeat > `(count ~foos)? > That seems to blow up: (defn binding-vec [foos] (vec (interleave names (take (count names) (repeat `(count ~foos)) (defmacro magic-fn [& forms] (let

Re: dynamically generated let bindings

2011-07-29 Thread Ken Wesson
On Fri, Jul 29, 2011 at 6:57 AM, Sam Aaron wrote: > However, something like the following doesn't work: > > (defn binding-vec [foos] >  `(vec (interleave ~names ~(take (count names) (repeat '`(count ~foos)) > > A, because the above code is probably incorrect (I just cobbled it together > for

Re: dynamically generated let bindings

2011-07-29 Thread Sam Aaron
Hi there, On 29 Jul 2011, at 10:05, Alan Malloy wrote: > > (defn binding-vec [foos] > ['size `(count ~foos)]) > > (defmacro magic-fn > [& forms] > (let [args (gensym 'args)] >`(fn [& ~args] > (let ~(binding-vec args) > ~@forms > > ((magic-fn (+ size 10)) 1 2) ;=> 12 Ac

Re: dynamically generated let bindings

2011-07-29 Thread Sam Aaron
Hi Alan, On 29 Jul 2011, at 10:05, Alan Malloy wrote: >> >> Sorry, I was just trying to simplify things to try and get directly to the >> meat of the problem. > > No apologies needed - reducing to a simple case is great. But here, > the simplification was probably too severe. > Sorry, I'm Eng

Re: dynamically generated let bindings

2011-07-29 Thread Alan Malloy
On Jul 29, 1:49 am, Sam Aaron wrote: > On 29 Jul 2011, at 07:22, Ken Wesson wrote: > > > On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose wrote: > >> I don't think it's very typical to pass a form to a function, unless > >> you plan on using eval at runtime. > > > Or it's a function called by a macro

Re: dynamically generated let bindings

2011-07-29 Thread Sam Aaron
On 29 Jul 2011, at 00:46, Kent wrote: > I'm not sure what you're trying to do with this and, based on that > ignorance, I'm not sure I think it's a great idea. Maybe you are being > a bit crazy, and maybe your a genius. Who am I to say? > > Here is a function that does what you want. The only

Re: dynamically generated let bindings

2011-07-29 Thread Sam Aaron
On 29 Jul 2011, at 07:22, Ken Wesson wrote: > On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose wrote: >> I don't think it's very typical to pass a form to a function, unless >> you plan on using eval at runtime. > > Or it's a function called by a macro to do some processing of forms. Yep, this is p

Re: dynamically generated let bindings

2011-07-28 Thread Ken Wesson
On Fri, Jul 29, 2011 at 12:49 AM, Jeff Rose wrote: > I don't think it's very typical to pass a form to a function, unless > you plan on using eval at runtime. Or it's a function called by a macro to do some processing of forms. -- Protege: What is this seething mass of parentheses?! Master: You

Re: dynamically generated let bindings

2011-07-28 Thread Jeff Rose
fn, passing the incoming args returning a vector of > alternating symbols and vals > * creates a let form using the vector of alternating symbols and vals > returned by the helper fn as the bindings > * contains some inner form that makes use of the bindings > > i.e. is it poss

Re: dynamically generated let bindings

2011-07-28 Thread Alan Malloy
t; * creates a let form using the vector of alternating symbols and vals > returned by the helper fn as the bindings > * contains some inner form that makes use of the bindings > > i.e. is it possible to implement something that allows the following to work: > > (defn binding-vec &g

Re: dynamically generated let bindings

2011-07-28 Thread Ken Wesson
and vals > * creates a let form using the vector of alternating symbols and vals > returned by the helper fn as the bindings > * contains some inner form that makes use of the bindings You probably want a macro rather than a normal function here, which is used in the body of a function

Re: dynamically generated let bindings

2011-07-28 Thread Kent
; alternating symbols and vals > * creates a let form using the vector of alternating symbols and vals > returned by the helper fn as the bindings > * contains some inner form that makes use of the bindings > > i.e. is it possible to implement something that allows the following to w

dynamically generated let bindings

2011-07-28 Thread Sam Aaron
urned by the helper fn as the bindings * contains some inner form that makes use of the bindings i.e. is it possible to implement something that allows the following to work: (defn binding-vec [args] ['size (count args)]) (defn mk-dynamically-bound-fn [form] ;; returns a fn with si

Re: Local bindings w/o let

2011-07-11 Thread Michael Wood
the above should be: (defn max1 [x] x) (defn max2 [x y] (if (> x y) x y)) (defn max3 ([x y & more] (reduce max (max x y) more))) :) > max1 has only the arg x. > max2 has only x and y > and max3 has x and y and maybe other arguments to select the maximum from. > The first &quo

  1   2   3   >