:
>
> (cond
> (odd? a) 1
>:let [a (quot a 2)]
>:when-let [x (fn-which-may-return-nil a),
> y (fn-which-may-return-nil (* 2 a))]
>:when (seq x)
>:do (println x)
>(odd? (+ x y)) 2
>:else 3)
>
> The :do performs a side-effec
Documentation for latest features in the 2.0.1 branch:
https://github.com/Engelberg/better-cond/tree/v2.0.1
An example:
(cond
(odd? a) 1
:let [a (quot a 2)]
:when-let [x (fn-which-may-return-nil a),
y (fn-which-may-return-nil (* 2 a))]
:when (seq x)
:do (println x
How would the :when and :do forms work?
Alan
On Wed, Oct 3, 2018 at 7:22 PM Mark Engelberg
wrote:
> This looks like a case of "convergent evolution".
>
> Having the ability to do a :let in the middle of a cond feels like one of
> those things that *should* be in the cor
Yes, I wouldn't have bothered if I had known about better-cond, so there
you go. I think I first wrote this code at Aviso at least five years ago.
On Wed, Oct 3, 2018 at 7:22 PM Mark Engelberg
wrote:
> This looks like a case of "convergent evolution".
>
> Having the a
a
'if-let' style nil-punning thing to a cond-let implementation but at that
point I imagine it more appropriate to take a step back instead :-).
I'm not convinced yet that it's worth thinking about it like this in a
dynamically typed language, but brought it up because there's a named
concept
But a Maybe/Nothing will short-circuit the whole flow where cond-let won't?
On Thursday, 4 October 2018 08:38:05 UTC-7, Moe Aboulkheir wrote:
>
> See https://funcool.github.io/cats/latest/#mlet for something closer to
> home, in the monadic vein.
>
>
> On Thu, Oct 4, 20
//github.com/janestreet/ppx_let#syntactic-forms-and-actual-rewriting
>
> But it can be made to work for async or options or whatever, too.
>
> We can put the async helpers in the same bucket:
> https://github.com/ztellman/manifold/blob/master/docs/deferred.md#let-flow
>
> The general ide
bucket:
https://github.com/ztellman/manifold/blob/master/docs/deferred.md#let-flow
The general idea is turning function application into something that looks
less nested.
On Wed, Oct 3, 2018 at 10:22 PM Mark Engelberg
wrote:
> This looks like a case of "convergent evolution".
>
>
This looks like a case of "convergent evolution".
Having the ability to do a :let in the middle of a cond feels like one of
those things that *should* be in the core language, so if it's not in
there, a bunch of people are naturally going to arrive at the same solution
and make
Is this a refinement of Mark Engelberg's "better-cond", or an alternative
approach?
I have not used better-cond myself, but it starts here:
https://dev.clojure.org/jira/browse/CLJ-200.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to
A micro library of a single macro, cond-let.
cond-let acts like a cond, but adds :let terms that are followed by a
binding form (like let).
This allows conditional code to introduce new local symbols; the result is
clearer, more linear code, that doesn't make a march for the right margin
his is small piece of code that is inspired by haxl, muse(
> https://github.com/kachayev/muse), urania(
> https://github.com/funcool/urania). Not a library.
>
> (defn remote-req [result]
> (Thread/sleep 1000)
> result)
>
> (defmacro plet [bindings & body]
> (let [bents (partiti
.
>
> (defn remote-req [result]
> (Thread/sleep 1000)
> result)
>
> (defmacro plet [bindings & body]
> (let [bents (partition 2 (destructure bindings))
> smap (into {} (map (fn [[b _]]
> [b `(deref ~b)])
>
Very nice! Kudos.
--
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,
Hi, folks
This is small piece of code that is inspired by haxl,
muse(https://github.com/kachayev/muse),
urania(https://github.com/funcool/urania). Not a library.
(defn remote-req [result]
(Thread/sleep 1000)
result)
(defmacro plet [bindings & body]
(let [bents (partition 2 (destruc
Also, have another look at
'(ret (- time-now start-time))
It will yield a list containing the symbol 'ret and a nested list
containing the symbol '- etc etc etc.
I think what you expected was a vector of two numbers.
--
You received this message because you are subscribed to the Google
contexts
where there isn't a do block implicitly, you can use do to sequence
expressions
On Tue, Oct 24, 2017 at 5:26 PM yihao yang <yangyihao1...@gmail.com> wrote:
> Hi, all
>
> I want to do sth. like query until timeout. So I write a function below.
> (defn wait-ls-ready
>
Hi, all
I want to do sth. like query until timeout. So I write a function below.
(defn wait-ls-ready
[]
(let [pair-fn (fn [] (
(Thread/sleep 1000)
(let [ret (try
(c/exec :ls
e, 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]
(mlet ~r ~@body))
rs handle this use case, which I feel should be pretty
> common.
>
> Given you have a series of business process steps, where the flow is too
> complex for the arrow macros, and you also like to name the step results
> descriptively, so you use let:
>
> (let [a (do-a ...)
>
, when it comes to handling Java exceptions in a monadic way, we can
look at the Try monad in Scala, that is exactly what we are searching for.
We have several libraries that implement monadic sugar in Clojure, and
`cats` [1] implements the try monad [2].
Example usage with `mlet` (monadic let, aka
On Monday, October 2, 2017 at 11:04:52 PM UTC+2, Didier wrote:
>
> > 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,
> 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 e
also like to name the step results
> descriptively, so you use let:
>
You are almost saying what I am thinking: this beast of a calculation has
to be broken up (into separate functions)! :)
>
> (let [a (do-a ...)
> b (do-b . a . .)
> c (do-c . a . b)]
>
Even in
> 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
30, 2017, at 3:14 PM, Didier <did...@gmail.com> 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 c
t;
>> 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.
>&g
y, 1 October 2017 21:00:31 UTC-7, Luke Burton wrote:
>
>
> On Sep 30, 2017, at 3:14 PM, Didier <did...@gmail.com >
> 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?
>
> On Sep 30, 2017, at 3:14 PM, Didier <didi...@gmail.com> 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
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
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
I'm curious how others handle this use case, which I feel should be pretty
common.
Given you have a series of business process steps, where the flow is too
complex for the arrow macros, and you also like to name the step results
descriptively, so you use let:
(let [a (do-a ...)
b (do-b
christopher.how...@qlfiles.net <mailto:christopher.how...@qlfiles.net>>
> wrote:
>
> When I run
>
> tutorial.core> (let [img (new-image 32 32)] (set-pixel img 10 10 cyan)
> (show img))
>
> from the REPL, this returns a javax.swing.JFrame object, a
-expression.
On Fri, May 26, 2017 at 11:54 AM Christopher Howard <
christopher.how...@qlfiles.net> wrote:
> When I run
>
> tutorial.core> (let [img (new-image 32 32)] (set-pixel img 10 10 cyan)
> (show img))
>
> from the REPL, this returns a javax.swing.JFrame objec
When I run
tutorial.core> (let [img (new-image 32 32)] (set-pixel img 10 10 cyan)
(show img))
from the REPL, this returns a javax.swing.JFrame object, and displays
the frame and image as expected. However, if put the same in
(defn -main
"Generates image."
[& args]
(let [
They are lazy -- change "for" to "doseq"
From: clojure@googlegroups.com [clojure@googlegroups.com] on behalf of Kevin
Kleinfelter [kleinfelter.gro...@gmail.com]
Sent: 17 May 2017 19:14
To: Clojure
Subject: Let and For Doesn't E
On 17 May 2017, at 19:14, Kevin Kleinfelter <kleinfelter.gro...@gmail.com>
wrote:
> I'm stumped by the behavior of the following code fragment. Can someone help
> me understand what's happening?
>
> This code:
> (println "Holding:" (:class holdin
Kevin Kleinfelter <kleinfelter.gro...@gmail.com> writes:
> I'm stumped by the behavior of the following code fragment. Can someone
> help me understand what's happening?
>
> *This code*:
> (println "Holding:" (:class holding))
> (let [t (:class holding)]
&g
I'm stumped by the behavior of the following code fragment. Can someone
help me understand what's happening?
*This code*:
(println "Holding:" (:class holding))
(let [t (:class holding)]
(for [x t] (println "here" x))
(for [x t] (println "there"
found curious. I'm probably missing something but here it
> > goes.
> >
> > The expression generated by the *loop* macro includes a wrapping *let
> > *when there is any de-structuring in the bindings.
> >
> > (require '[clojure.walk :as walk])
> > (w
On 03/06/2017 03:28 PM, juan.facorro wrote:
> While I was debugging some code I found something related to the *loop
> *macro that I found curious. I'm probably missing something but here it
> goes.
>
> The expression generated by the *loop* macro includes a wrapping *let
> *wh
While I was debugging some code I found something related to the *loop *macro
that I found curious. I'm probably missing something but here it goes.
The expression generated by the *loop* macro includes a wrapping *let *when
there is any de-structuring in the bindings.
(require '[clojure.walk
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
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/9
gow...@gmail.com> wrote:
> 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
>
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:
>
>
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 t
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]
(c
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't
ecursive
> fibonacci function interactively. So naturally, the first thing my fingers
> went to was:
>
> (let [fib (fn [x]
> (cond
> (< x 2) x
> :else (+ (fib (- x 2)) (fib (- x 1)]
> (fib 5))
>
> which threw an unable to resolve symbol error because i
...
So for obscure reasons, I found myself trying to use a naive recursive
fibonacci function interactively. So naturally, the first thing my fingers
went to was:
(let [fib (fn [x]
(cond
(< x 2) x
:else (+ (fib (- x 2)) (fib (- x 1)]
(fib 5))
which threw an unable to reso
as different behavior
> to the letted one?
> This is especially confusing to me since the #() special form one works as
> I expect.
>
> (def sum-partial-def (partial reduce +))
>
> (let [sum-partial (partial reduce +)
> sum-# #(reduce + %1)
> nums [1 2 3 4]]
> [
n to me why the def-ed partial has different behavior
> to the letted one?
> This is especially confusing to me since the #() special form one works as
> I expect.
>
> (def sum-partial-def (partial reduce +))
>
> (let [sum-partial (partial reduce +)
> sum-# #(reduce + %1)
I'm confused by the following code.
Could someone explain to me why the def-ed partial has different behavior
to the letted one?
This is especially confusing to me since the #() special form one works as
I expect.
(def sum-partial-def (partial reduce +))
(let [sum-partial (partial reduce
Here is the if-let*:
(defmacro if-let*
([bindings then]
`(if-let* ~bindings ~then nil))
([bindings then else]
(if (seq bindings)
`(if-let [~(first bindings) ~(second bindings)]
(if-let* ~(drop 2 bindings) ~then ~else)
~(if-not (second bindings) else))
then)))
And when-let*:
(defmacro when-let
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
(defmacro if-all-let [bindings then else]
(reduce (fn [subform binding]
`(if-let [~@binding] ~subform ~else))
then (reverse (partition 2 bindings
I quoted the function from p259 of Chas Emerick, Brian Carper, Christophe
Grand-Clojure Programming-O'Reilly Media (2012
Disclaimer: I do not make decisions on what gets into clojure.core.
Here is a page that gives some reasons why most things don't get into
clojure.core:
http://dev.clojure.org/display/design/Why+Feature+X+Was+Declined
More specifically on if-all-let and things like it, many people seem
, then respond with this, otherwise I do not see a reason to
post this.
Thanks,
Alex
On Thursday, June 18, 2015 at 3:35:53 PM UTC-5, raould wrote:
http://lmgtfy.com/?q=clojure+%22let+vs.+let*%22
--
You received this message because you are subscribed to the Google
Groups Clojure group
My apologies (sincerely). Won't use that again.
--
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
PM UTC-5, raould wrote:
http://lmgtfy.com/?q=clojure+%22let+vs.+let*%22
--
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
, then respond with this, otherwise I do not see a reason to
post this.
Thanks,
Alex
On Thursday, June 18, 2015 at 3:35:53 PM UTC-5, raould wrote:
http://lmgtfy.com/?q=clojure+%22let+vs.+let*%22
--
You received this message because you are subscribed to the Google
Groups Clojure
I don't think this is a let me google that for you question. Let vs let* in
Clojure is not at all the same as the popular usages of these forms in popular
lisp dialects like Common Lisp.
I've thought it was confusing why let* existed in Clojure since let binding is
only done in a sequential
In common lisp, 'let' didn't evaluate it's bindings in any guaranteed order
(well, it is specified as being evaluated in parallel), however, 'let*'
evaluated it's bindings in order from left to right.
This enabled you to use the sequentially previous bindings in the
evaluation of later
On Thursday, June 18, 2015 at 4:29:55 PM UTC-4, Johannes wrote:
Hi!
I cannot figure out, what the difference between let and let* is. Can
anyone enlighten me?
Let is a macro that wraps let* and adds destructuring. There's a similar
relationship between fn and fn*, letfn and letfn
Hi!
I cannot figure out, what the difference between let and let* is. Can
anyone enlighten me?
Johannes
--
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
http://lmgtfy.com/?q=clojure+%22let+vs.+let*%22
--
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
thanks
Am Donnerstag, 18. Juni 2015 22:35:53 UTC+2 schrieb raould:
http://lmgtfy.com/?q=clojure+%22let+vs.+let*%22
--
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
Basically you the user should not worry about the starred versions
On Thu, Jun 18, 2015 at 1:40 PM Johannes bra...@nordakademie.de wrote:
thanks
Am Donnerstag, 18. Juni 2015 22:35:53 UTC+2 schrieb raould:
http://lmgtfy.com/?q=clojure+%22let+vs.+let*%22
--
You received this message
I'll chime in with my opinion on this topic.
I think the existing if-let and similar forms that have a limitation of only
allowing a single binding is a confusing restriction to place on the familiar
binding vector construct. I've always been a little uneasy about repurposing
binding vectors
Where does if-let-all serve people best? Can anyone help me find the right
clojure project to contribute to?
On Friday, June 5, 2015 at 2:44:22 PM UTC+9, crocket wrote:
The macro below is called if-let-all.
(defmacro if-let-all
if-let-all evaluates every local binding sequentially
It evaluates true-case only if every local binding evaluates to true values.
false-case has no access to local bindings.
(defmacro if-let-all
if-let-all evaluates every local binding sequentially and evaluates
true-case only if every local binding is a truthy value.
true-case has access
:
It evaluates true-case only if every local binding evaluates to true values.
false-case has no access to local bindings.
(defmacro if-let-all
if-let-all evaluates every local binding sequentially and evaluates
true-case only if every local binding is a truthy value.
true-case has
Dunaj has support for multiple bindings in if-let since version
0.5. http://www.dunaj.org/dunaj.flow.api.html#if_let
Related design page that discusses possible approaches is
at https://github.com/dunaj-project/dunaj/wiki/Conditionals
Jozef
On Tuesday, June 9, 2015 at 4:00:35 PM UTC+2, Lars
At least based on my uses, I agree that this would likely bring the most
use of the now unused binding space in cores if-let. I can't think of any
useful alternatives.
Syntactically though, one could worry that the additional bindings would be
read as regular let bindings and worry about
There's a variant of this in one of my projects as well.
If this is in several utility libraries *and* half the world keeps
Greenspunning versions of it in their own projects, then it might be
something that belongs in core ...
--
You received this message because you are subscribed to the
On Jun 9, 2015, at 3:51 PM, Leon Grapenthin grapenthinl...@gmail.com wrote:
Syntactically though, one could worry that the additional bindings would be
read as regular let bindings and worry about the language clarity.
One of the main points that I seem to recall from previous discussions has
I actually wish this was how the if-let macro in core worked. Once in a
blue moon I end up writing nested if-let statements or an if-let with a
nested let. Both of these cases look so ridiculous I often re-write the
the code just avoid it.
On Tuesday, June 9, 2015 at 2:00:53 PM UTC+2
this if-let-all do not support destructure, I writed a improved
https://gist.github.com/gfZeng/8e8e18f148d5742b064c
On Tuesday, June 9, 2015 at 8:00:53 PM UTC+8, crocket wrote:
It evaluates true-case only if every local binding evaluates to true values.
false-case has no access to local
Yes, if-and-let is similar to if-let-all.
On Friday, June 5, 2015 at 10:47:24 PM UTC+9, Fluid Dynamics wrote:
On Friday, June 5, 2015 at 1:53:07 AM UTC-4, crocket wrote:
Ouch, I didn't write. Gary Fredericks wrote it. I simply modified his
if-let-all macro a little bit.
On Friday, June 5
On Friday, June 5, 2015 at 1:53:07 AM UTC-4, crocket wrote:
Ouch, I didn't write. Gary Fredericks wrote it. I simply modified his
if-let-all macro a little bit.
On Friday, June 5, 2015 at 2:44:22 PM UTC+9, crocket wrote:
The macro below is called if-let-all.
(defmacro if-let-all
The macro below is called if-let-all.
(defmacro if-let-all
if-let-all evaluates every local binding sequentially and evaluates
true-case only if every local binding is a truthy value.
true-case has access to all local bindings, but false-case doesn't have access
to local bindings
Ouch, I didn't write. Gary Fredericks wrote it. I simply modified his
if-let-all macro a little bit.
On Friday, June 5, 2015 at 2:44:22 PM UTC+9, crocket wrote:
The macro below is called if-let-all.
(defmacro if-let-all
if-let-all evaluates every local binding sequentially and evaluates
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 you had
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
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
2015-02-12 3:06 GMT+01:00 gvim gvi...@gmail.com:
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
(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
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
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
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
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
Hi,
On Feb 11, 2015, at 5:42 PM, gvim gvi...@gmail.com 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
On 12 February 2015 at 02:06, gvim gvi...@gmail.com 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
Old thread, but still works great, thanks!
Den onsdag den 28. april 2010 03.25.26 UTC+2 skrev ataggart:
Inspired from an earlier discussion, I've written a macro that allows
let-style binding values to be try'd, and still available to catch/
finally clauses. E.g.:
(try-let [from (API
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))
~(if-and-let* (drop 2 bindings
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
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
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? bindings
Hi,
the following form doesn't compile and I see no reason why it shouldn't:
(if-let [a a] a (assert a))
IMHO it is a bug.
If anyone is of a different opinion please share.
Thanks,
--
László Török
--
You received this message because you are subscribed to the Google
Groups Clojure group
1 - 100 of 669 matches
Mail list logo