ncy-information>
improves
error messages for vector destructuring. Instead of a low-level error
referencing gensyms and expanded code, now destructuring is a first-class
concept in error messages.
Check out the runnable demo <https://github.com/typedclojure/let-error-demo> to
see the
I was just reading an article on Kotlin and noticed they have nearly
identical destructuring syntax as in Clojure:
for ((k, v) in map) { println(“$k -> $v”) }
Kotlin can also be compiled into JavaScript ES5.1 to target browsers, just
like with ClojureScript.
--
You received this mess
There is also this sort of solution:
(def xs (range 9))
(let [ [[a b c] mid3 [d e f]] (partition 3 xs) ]
[a b c mid3 d e f])
=>
(0 1 2 (3 4 5) 6 7 8)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to
args:(1 2 3 4 5 6 7 8 9 10)
On Wed, May 10, 2017 at 9:04 PM, Alan Thompson <clooj...@gmail.com> wrote:
> Don't try to force the destructuring DSL to do more than it was intended
> to do. Just do it manually (or write a macro if you really insist):
>
>
>
> (defn foo
> [&a
Don't try to force the destructuring DSL to do more than it was intended to
do. Just do it manually (or write a macro if you really insist):
(defn foo
[& args]
(let [ [a b c] (take 3 args)
mid3 (take 3 (drop 3 args))
[g h i] (drop 6 args) ]
(when (< 9 (cou
Can I destructure a list, assigning the first and last few items
individually, while putting several items from the middle into a list?
I see that I can assign a list:
(let [a '( 1 2 3 4)] ...)
I can destructure the list as a whole:
(let [[a b c d] '(1 2 3 4)] ...)
I can destructure the
There are two different concerns in what people refer to as "pattern
matching": binding and flow-control. Destructuring only addresses binding.
Pattern matching emphasizes flow control, and some binding features
typically come along for free with whatever syntax it uses. (But
On 27 Jan 2017, at 07:04, Didier <didi...@gmail.com> wrote:
> Some languages have pattern matching, and Clojure is said to not have it
> (without a library), but it does have destructuring.
>
> It seems to me that destructuring is the same as pattern matching, except
> tha
Some languages have pattern matching, and Clojure is said to not have it
(without a library), but it does have destructuring.
It seems to me that destructuring is the same as pattern matching, except that
it can only be used inside function arguments, where as pattern matching can
also be used
Ah! Thank you, Francis! And sorry for the belated reply!
I ran into a terse example of it at
<https://clojure.org/guides/destructuring#_associative_destructuring> (see
"(def options '(:debug true))") and was scratching my head. Now that you
explained it though, I r
A list/seq (not a vector) which is destructured as a map will be first read
into a map as by (apply hash-map the-seq)
This curiosity exists so the "keyword argument" idiom works:
(defn my-options [_ & {:keys [a b] :as options}]
options)
=> #'user/my-options
(my-options nil :a 1 :b 2 :c 3)
=>
I've used associative destructing in the usual fashion:
some-app.core=> (def m {:a 1 :b 2})
#'some-app.core/m
some-app.core=> (let [{:keys [a b]} m] (str a "-" b))
"1-2"
but what is going on here:
some-app.core=> (def li '(:a 1 :b 2))
#'some-app.core/li
;; Wat?
see links in your current styling.
>
> [image: Inline image 1]
>
> On Thu, Jan 5, 2017 at 9:18 AM, Alex Miller <a...@puredanger.com> wrote:
>
>> I thought this might be interesting to some here:
>>
>> http://blog.cognitect.com/blog/2017/1/3/spec-destructuring
&
g.cognitect.com/blog/2017/1/3/spec-destructuring
>
>
> --
> 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 modera
I thought this might be interesting to some here:
http://blog.cognitect.com/blog/2017/1/3/spec-destructuring
--
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 post
In case it's not clear from the above, {:keys [...]} is a
technique for *map* destructuring of associative data structures.
(let [{:keys [a b]} {:a 1 :b 2}] [a b])
[1 2]
As documented at http://clojure.org/reference/special_forms, :keys
takes a vector of the symbols to bind.
--
You received
that's an implementation detail you should not rely on.
it only works to support keyword arguments to functions
On 23 Jan 2016 17:36, "Harold" <hhaus...@gmail.com> wrote:
> Hello,
>
> While destructuring yesterday, I encountered this difference:
>
> > (let [
On Jan 23, 2016 11:36 AM, "Harold" <hhaus...@gmail.com> wrote:
>
> Hello,
>
> While destructuring yesterday, I encountered this difference:
>
> > (let [{:keys [:a :b]} '(:a 1 :b 2)] [a b])
> [1 2]
>
> > (let [{:keys [:a :b]} [:a 1 :b 2]] [a b])
Hello,
While destructuring yesterday, I encountered this difference:
> (let [{:keys [:a :b]} '(:a 1 :b 2)] [a b])
[1 2]
> (let [{:keys [:a :b]} [:a 1 :b 2]] [a b])
[nil nil]
I have read some of the relevant documentation and some related blog posts,
but I am still having trouble expl
/get map__1202 :port)
host (clojure.core/get map__1202 :host)]
So, if the destructuring is re-written by macroexpand, then I can
reasonably assume that destructuring is implemented as a macro, yes?
--
You received this message because you are subscribed to the Google
Groups Clojure group
map__1202 :tls)
user (clojure.core/get map__1202 :user)
port (clojure.core/get map__1202 :port)
host (clojure.core/get map__1202 :host)]
So, if the destructuring is re-written by macroexpand, then I can
reasonably assume that destructuring is implemented as a macro, yes?
--
You received
destructuring into something of your own,
your best bet is generally to write a macro that expands into a fn or let
form and let that handle the destructuring.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email
I created a ticket and posted a patch:
http://dev.clojure.org/jira/browse/CLJ-1613
On 12 December 2014 at 08:35, Michał Marczyk michal.marc...@gmail.com wrote:
(let [foo 1
bar 2
{:keys [bar foo]
:or {foo 3 bar (inc foo)}} {}]
{:foo foo :bar bar})
;= {:foo 3, :bar
If I make my defaults on a :keys :or destructuring depend on the values of
other keys, I *can* get a compile-time error, depending on what order I
give the keys https://gist.github.com/MichaelBlume/4891dafdd31f0dcbc727
Is this on-spec behavior? Should the former be allowed but not the latter
my defaults on a :keys :or destructuring depend on the values of
other keys, I *can* get a compile-time error, depending on what order I
give the keys https://gist.github.com/MichaelBlume/4891dafdd31f0dcbc727
Is this on-spec behavior? Should the former be allowed but not the latter?
Should
11, 2014 6:11:59 PM UTC-5, Michael Blume wrote:
If I make my defaults on a :keys :or destructuring depend on the values of
other keys, I *can* get a compile-time error, depending on what order I
give the keys https://gist.github.com/MichaelBlume/4891dafdd31f0dcbc727
Is this on-spec behavior
my defaults on a :keys :or destructuring depend on the values
of other keys, I *can* get a compile-time error, depending on what order I
give the keys https://gist.github.com/MichaelBlume/4891dafdd31f0dcbc727
Is this on-spec behavior? Should the former be allowed but not the
latter? Should both
Common Lisp has a really well thought approach to parameter lambda lists.
If you feel strongly about resolving this ambiguity and enforcing
consistency around sequential binding in the destructuring syntax, perhaps
that would be a good place to root a design you can flesh out in Jira.
Here's
in the destructuring syntax, perhaps that would be
a good place to root a design you can flesh out in Jira. Here's a resource
you might find interesting as a starting point:
http://www.lispworks.com/documentation/HyperSpec/Body/03_dad.htm
On Thursday, December 11, 2014 11:55:36 PM UTC-5, Michael Blume wrote
:mandatory {:a Number :b String})])
(defn mult-arity [n s] {:a n :b s})
but with functions that use destructuring in their body, I run into
problems.
;; Does not work.
(ann map-span [Map Fn - Map])
(defn map-span [m f] (into {} (for [[k v] m] [k (f v)])))
clojure.lang.ExceptionInfo
-arity [n s] {:a n :b s})
but with functions that use destructuring in their body, I run into
problems.
;; Does not work.
(ann map-span [Map Fn - Map])
(defn map-span [m f] (into {} (for [[k v] m] [k (f v)])))
clojure.lang.ExceptionInfo: Type Checker: Found 8 errors :: {:type-error
:top
(ann plus1 [Number - Number])
(defn plus1 [n] (+ n 1))
;; Works as expected
(ann mult-arity [Number String - (HMap :mandatory {:a Number :b
String})])
(defn mult-arity [n s] {:a n :b s})
but with functions that use destructuring in their body, I run into
problems.
;; Does not work
String - (HMap :mandatory {:a Number :b
String})])
(defn mult-arity [n s] {:a n :b s})
but with functions that use destructuring in their body, I run into
problems.
;; Does not work.
(ann map-span [Map Fn - Map])
(defn map-span [m f] (into {} (for [[k v] m] [k (f v
destructuring in their body, I run into
problems.
;; Does not work.
(ann map-span [Map Fn - Map])
(defn map-span [m f] (into {} (for [[k v] m] [k (f v)])))
clojure.lang.ExceptionInfo: Type Checker: Found 8 errors ::
{:type-error :top-level-error, :errors (#ExceptionInfo
Why is it that although this works:
~~~clojure
(defn foo [ args] (let [{:keys [a b]} args] (str a \~ b)))
;;= #'some-app.core/foo
(foo :a 1 :b 2)
;;= 1~2
~~~
this does not:
~~~clojure
(let [{:keys [a b]} [:a 1 :b 2 :c 3]] (str a \~ b))
;;= ~
~~~
?
And even stranger, *this* *does* work:
The reason is that in the macroexpansion of let, map-based destructuring
has a seq? test which the list passes but the vector doesn't:
(clojure.pprint/pprint (macroexpand-1 '(let [{:keys [a b]} [:a 1]] a)))
(let*
[map__34214
[:a 1]
map__34214
(if
(clojure.core/seq? map__34214
... the other half of the answer being that when you have rest args with
(defn foo [ args] ...), args is bound to a seq.
On Wed, Aug 27, 2014 at 11:27 AM, Ben Wolfson wolf...@gmail.com wrote:
The reason is that in the macroexpansion of let, map-based destructuring
has a seq? test which
Apparently a list can be destructured as a map, but a vector cannot.
The args syntax returns the result as a list, not a vector.
- James
On 27 August 2014 19:20, John Gabriele jmg3...@gmail.com wrote:
Why is it that although this works:
~~~clojure
(defn foo [ args] (let [{:keys [a b]}
.
- James
On 10 June 2014 16:43, Francesco Lunelli francesc...@gmail.com
wrote:
Hello everybody, I have a newbie question about destructuring and
assigning and didn't find an answer in documentation or books.
I have a list that contains an arbitrary number of elements for
example '(one
Hello everybody, I have a newbie question about destructuring and assigning
and didn't find an answer in documentation or books.
I have a list that contains an arbitrary number of elements for example
'(one two three ...) I now only that elements are strings.
I need to to take every element
destructuring and
assigning and didn't find an answer in documentation or books.
I have a list that contains an arbitrary number of elements for example
'(one two three ...) I now only that elements are strings.
I need to to take every element and use it as the name of a variable
inside a let
have a newbie question about destructuring and
assigning and didn't find an answer in documentation or books.
I have a list that contains an arbitrary number of elements for example
'(one two three ...) I now only that elements are strings.
I need to to take every element and use
.
- James
On 10 June 2014 16:43, Francesco Lunelli francesc...@gmail.com wrote:
Hello everybody, I have a newbie question about destructuring and
assigning and didn't find an answer in documentation or books.
I have a list that contains an arbitrary number of elements for example
'(one
about destructuring and
assigning and didn't find an answer in documentation or books.
I have a list that contains an arbitrary number of elements for example
'(one two three ...) I now only that elements are strings.
I need to to take every element and use it as the name of a variable
a map, but without knowing more about the
purpose, it's difficult to say.
- James
On 10 June 2014 16:43, Francesco Lunelli francesc...@gmail.com wrote:
Hello everybody, I have a newbie question about destructuring and
assigning and didn't find an answer in documentation or books.
I have
The as- macro doesn't work with destructuring. This is invalid code:
(- [1 2]
(as- [a b]
[a (inc b)]
[(inc a) b]))
Because it is expanded to:
(let [[a b] [1 2]
[a b] [a (inc b)]
[a b] [(inc a) b]]
[a b]) ;; this last expression
the reason why existing let key destructuring is
backwards
To me, it seems the fictional leth example is much simpler -- the mental
model is just do pattern matching
The current let example seems to be: okay, um, so for cat, you look at
:cat, then you look at :foo, then you think (:cat (:foo
} a]
[cat dog bar])
I don't understand the reason why existing let key destructuring is
backwards
To me, it seems the fictional leth example is much simpler -- the mental
model is just do pattern matching
The current let example seems to be: okay, um, so for cat, you look at
:cat, then you
On 18/01/14, Alex Miller wrote:
I have some sympathy for this view of things as it was a question I had
while learning Clojure as well.
The general justification for the current behavior is that the thing being
bound is always on the left and the expression defining it is always on the
Map keys need to be unique. Therefore, it's tidy for the symbol to be the
key to the destructuring map.
On Saturday, January 18, 2014 2:57:09 PM UTC-5, Alex Miller wrote:
I have some sympathy for this view of things as it was a question I had
while learning Clojure as well.
The general
On Saturday, January 18, 2014 2:19:08 PM UTC-6, Stefan Kanev wrote:
On 18/01/14, Alex Miller wrote:
I have some sympathy for this view of things as it was a question I had
while learning Clojure as well.
The general justification for the current behavior is that the thing
being
b2 b])
(foo {:a 1 :b {:b1 2 :b2 3}})
; = [1 2 3 {:b2 3, :b1 2}]
On 22 November 2013 19:06, David James david...@gmail.com javascript:
wrote:
I made a quick destructuring code walkthrough at
https://github.com/xpe/clj-destruct/blob/master/src/destruct/core.cljhttps://www.google.com
No prob, you might also want to check Jay Fields' blog post (one of
the most often cited resources) for more destructuring options:
http://blog.jayfields.com/2010/07/clojure-destructuring.html
On 23 November 2013 18:19, David James davidcja...@gmail.com wrote:
Thanks Karsten! I updated
I made a quick destructuring code walkthrough at
https://github.com/xpe/clj-destruct/blob/master/src/destruct/core.clj
I was hoping to show how to nest :keys inside of :keys but failed. Did I
overlook something?
--
--
You received this message because you are subscribed to the Google
Groups
a quick destructuring code walkthrough at
https://github.com/xpe/clj-destruct/blob/master/src/destruct/core.clj
I was hoping to show how to nest :keys inside of :keys but failed. Did I
overlook something?
--
--
You received this message because you are subscribed to the Google
Groups Clojure
thanks !!
On Saturday, September 28, 2013 9:57:13 PM UTC-3, Ambrose Bonnaire-Sergeant
wrote:
The or syntax should be {lastname Meneses}
Thanks,
Ambrose
On Sun, Sep 29, 2013 at 8:54 AM, Daniel Meneses Báez
dap...@gmail.comjavascript:
wrote:
I think that the second and third lines in
No problem.
On Mon, Sep 30, 2013 at 9:11 AM, Daniel Meneses dap...@gmail.com wrote:
thanks !!
On Saturday, September 28, 2013 9:57:13 PM UTC-3, Ambrose
Bonnaire-Sergeant wrote:
The or syntax should be {lastname Meneses}
Thanks,
Ambrose
On Sun, Sep 29, 2013 at 8:54 AM, Daniel
I think that the second and third lines in the following example should
yield the same output...
*user= (defn my-name [ {:keys [name lastname] :or {:lastname Meneses}}]
(str name lastname))*
*#'user/my-name*
*user= (my-name :name Daniel :lastname Meneses)*
*Daniel Meneses*
*user= (my-name :name
The or syntax should be {lastname Meneses}
Thanks,
Ambrose
On Sun, Sep 29, 2013 at 8:54 AM, Daniel Meneses Báez dap...@gmail.comwrote:
I think that the second and third lines in the following example should
yield the same output...
*user= (defn my-name [ {:keys [name lastname] :or
Consider the following:
(let [ [{:keys [] :as m}] [:a 1 :b 2 :c 3]]
m)
== {:a 1 :b 2 :c 3}
Is there a shorter form of [{:keys [] :as m}]?
--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
Well... I'm a dingus.
[{:as m}]
On Thursday, 6 June 2013 15:23:22 UTC-4, JvJ wrote:
Consider the following:
(let [ [{:keys [] :as m}] [:a 1 :b 2 :c 3]]
m)
== {:a 1 :b 2 :c 3}
Is there a shorter form of [{:keys [] :as m}]?
--
--
You received this message because you are
[ {:as m}]
On Fri, Jun 7, 2013 at 3:23 AM, JvJ kfjwhee...@gmail.com wrote:
Consider the following:
(let [ [{:keys [] :as m}] [:a 1 :b 2 :c 3]]
m)
== {:a 1 :b 2 :c 3}
Is there a shorter form of [{:keys [] :as m}]?
--
--
You received this message because you are subscribed to
On 06/06/13 20:23, JvJ wrote:
Is there a shorter form of [{:keys [] :as m}]?
if you don't care about the actual keys just do this:
[ {:as m}]
HTH,
Jim
--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
I just realized it after I posted, but thanks for the help anyways.
On Thursday, 6 June 2013 15:27:28 UTC-4, Jim foo.bar wrote:
On 06/06/13 20:23, JvJ wrote:
Is there a shorter form of [{:keys [] :as m}]?
if you don't care about the actual keys just do this:
[ {:as m}]
HTH,
Jim
.
On Friday, May 3, 2013 10:22:59 PM UTC+3, Sean Corfield wrote:
The :as key binds the entire _original_ map.
The :or defaults apply only to the bound variables extracted from the
map.
It caught me out when I first used map destructuring but I soon got
used
Hi Ryan,
I actually run into this quite often and feel that it's something that's
missing from destructuring:
http://grokbase.com/t/gg/clojure/128z9e3sqj/possible-to-merge-destructuring-or-defaults-with-as
Basically, I'd advocate the addition of a new `:merge-as` destructure
option
UTC+3, Peter Taoussanis wrote:
Hi Ryan,
I actually run into this quite often and feel that it's something that's
missing from destructuring:
http://grokbase.com/t/gg/clojure/128z9e3sqj/possible-to-merge-destructuring-or-defaults-with-as
Basically, I'd advocate the addition of a new `:merge
Hello all,
I have a question regarding the default values when destructuring with :keys
Let's assume that we have the following function:
*(defn my-function [{:keys [my-key] :or {my-key 5} :as params}]
(str my-key value is (:my-key params)))*
A few test runs:
*user= (my-function {:my
all,
I have a question regarding the default values when destructuring with
:keys
Let's assume that we have the following function:
*(defn my-function [{:keys [my-key] :or {my-key 5} :as params}]
(str my-key value is (:my-key params)))*
A few test runs:
*user= (my-function {:my
} :as params}]
* (str my-key value is my-key))*
On Friday, May 3, 2013 1:52:46 PM UTC-5, Ryan wrote:
Hello all,
I have a question regarding the default values when destructuring with
:keys
Let's assume that we have the following function:
*(defn my-function [{:keys [my-key] :or {my-key 5
The :as key binds the entire _original_ map.
The :or defaults apply only to the bound variables extracted from the map.
It caught me out when I first used map destructuring but I soon got used to it.
On Fri, May 3, 2013 at 12:08 PM, Ryan arekand...@gmail.com wrote:
Thanks Anthony for your
binds the entire _original_ map.
The :or defaults apply only to the bound variables extracted from the map.
It caught me out when I first used map destructuring but I soon got used
to it.
On Fri, May 3, 2013 at 12:08 PM, Ryan areka...@gmail.com javascript:
wrote:
Thanks Anthony
out when I first used map destructuring but I soon got used
to it.
On Fri, May 3, 2013 at 12:08 PM, Ryan areka...@gmail.com wrote:
Thanks Anthony for your reply but I was already aware of that. I was
hoping
for some solution which would took care of the binding if :as was
provided
Ah, the default nap is a nice idea :)
--
--
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
to the bound variables extracted from the map.
It caught me out when I first used map destructuring but I soon got used
to it.
On Fri, May 3, 2013 at 12:08 PM, Ryan areka...@gmail.com wrote:
Thanks Anthony for your reply but I was already aware of that. I was
hoping
for some solution which would
[{a :a, b :b, c :c, :as m :or {a 2 b 3}} {:a 5 :c 6}]
[a b c m])
-[5 3 6 {:c 6, :a 5}]
On Friday, April 12, 2013 6:00:27 PM UTC-4, henry clifford wrote:
I'm trying to use the :or destructuring syntax as seen here applied to a
map
(def point {:y 7})
(let [{:keys [x y] :or {x 0 y 0}} point
Fantastic, thank you!
On Friday, April 12, 2013 11:13:23 PM UTC+1, John Hume wrote:
You can use a map destructuring form on a vector like so:
(let [{x 0 y 1 :or {x 0 y 0}} [7]] [x y])
returns [7 0]
On Fri, Apr 12, 2013 at 5:00 PM, henry clifford
h.a.cl...@gmail.comjavascript:
wrote
I'm trying to use the :or destructuring syntax as seen here applied to a map
(def point {:y 7})
(let [{:keys [x y] :or {x 0 y 0}} point]
(println x: x y: y))
x: 0 y: 7
but I can't get this to work with vectors:
(def point [7])
(let [[x y :or [0 0]] point]
(println x: x y: y))
what' I'm
You can use a map destructuring form on a vector like so:
(let [{x 0 y 1 :or {x 0 y 0}} [7]] [x y])
returns [7 0]
On Fri, Apr 12, 2013 at 5:00 PM, henry clifford h.a.cliff...@gmail.com wrote:
I'm trying to use the :or destructuring syntax as seen here applied to a map
(def point {:y 7
Pretty sure it's just a typo / bug. I think it should read:
{servlet ::servlet
type ::type
:or {type :jetty}
:as service-map}
On Tue, Mar 19, 2013 at 10:09 PM, Matching Socks phill.w...@gmail.com wrote:
I'm puzzled by two :or syntaxes that are used in io.pedestal.service.http,
Yes. Apparently you can put whatever garbage you want into the `:or` map:
each local is looked up in that map to see if it has a default, but nobody
ever checks to see if there are unused keys in the defaults map. So `:or
{::type :jety}` has no impact at all on the generated code: there is no
this---layer 1:
{w :weigths, u :uni-probs, b :bi-probs, t :tri-probs}
Then, instead of an atomic w, recursively substitute another
destructuring form, which will destructure the value of that w (which is
also a map). This form is {:keys [w1 w2 w3]}. That gives you complete
layer 2:
{{:keys [w1
On Tue, Mar 19, 2013 at 2:58 PM, Jim - FooBar(); jimpil1...@gmail.com wrote:
awsome!...the full thing actually is {{:keys [w1 w2 w3]} :weights u
:uni-probs b :bi-probs t :tri-probs}
You might also consider
{:keys [uni-probs bi-probs tri-probs]} {:keys [w1 w2 w3]} :weights}
--
--
You received
Hello all,
can anyone help me destructure the following map in order to access
directly w1 w2 w3 ? I've been trying for 20 minutes now! (how useless
am I? :( )
{:weights {:w1 0.2 :w2 0.3 :w3 0.5}
:uni-probs {...} :bi-probs {...} :tri-probs {...}}
thanks,
Jim
--
--
You received this
On Tuesday, March 19, 2013 8:39:26 PM UTC+1, Jim foo.bar wrote:
Hello all,
can anyone help me destructure the following map in order to access
directly w1 w2 w3 ? I've been trying for 20 minutes now! (how useless
am I? :( )
{:weights {:w1 0.2 :w2 0.3 :w3 0.5}
:uni-probs {...}
On 19/03/13 19:49, Marko Topolnik wrote:
{{:keys [w1 w2 w3]} :weights}
awsome!...the full thing actually is {{:keys [w1 w2 w3]} :weights u
:uni-probs b :bi-probs t :tri-probs}
I always get confused when the order changes like that...thanks for
unblocking me Marko :)
Jim
--
--
You
Think of it in layers, like this---layer 1:
{w :weigths, u :uni-probs, b :bi-probs, t :tri-probs}
Then, instead of an atomic w, recursively substitute another destructuring
form, which will destructure the value of that w (which is also a map).
This form is {:keys [w1 w2 w3]}. That gives you
substitute another
destructuring form, which will destructure the value of that w (which
is also a map). This form is {:keys [w1 w2 w3]}. That gives you
complete layer 2:
{{:keys [w1 w2 w3]} :weigths, u :uni-probs, b :bi-probs, t :tri-probs}
On Tuesday, March 19, 2013 8:58:43 PM UTC+1, Jim foo.bar
I'm puzzled by two :or syntaxes that are used in io.pedestal.service.http,
from [io.pedestal/pedestal.service 0.1.1-SNAPSHOT], which is where
following along with the Getting Started got me.
In one place, it pairs :or with a map whose keys are symbols being bound in
the outer form:
{routes
a minor thing.
which do you prefer?
(defn blah [x y zs] ...) , or, (defn blah [x y zs] ...)
clojure core usually uses the first form. assoc, conj and so forth
I have used this because it seems nicer for the caller
(blah x y z1 z2 z3) rather than (blah x y [z1 z2 z3])
However, if you
One criterion would be how often you expect to call with zero or one z. If
a lot, use ; otherwise prefer calling with an explicit collection.
On Wednesday, March 6, 2013 12:45:38 PM UTC+1, Dave Sann wrote:
a minor thing.
which do you prefer?
(defn blah [x y zs] ...) , or, (defn blah [x y
I personally think the first (current) approach is better since it ensures
that the abstraction is not leaky from a caller's perspective, e,g. as a
user I want to be able to type (+ 1 2 3 4 5) instead of (+ 1 2 [3 4 5]).
The fact that the last 3 arguments end up as a collection inside the
I don't think that's the question here: x and y are each their own kind of
argument, followed by zero or more same-kinded arguments. Take dissoc as an
example and compare with select-keys.
On Wednesday, March 6, 2013 12:54:13 PM UTC+1, Achint Sandhu wrote:
I personally think the first
I wrote this little macro today that lets you do it. However, I feel like
it was implemented in a pattern match library or something... but I'm not
sure.
Someone let me know if I'm re-inventing the wheel.
If I'm not, here's the code:
(defn re-bind-fn
[str re bnds act forms]
`(let
}} '()] message)
IllegalArgumentException No value supplied for key: null
clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)
I worked around it by doing the destructuring in two steps in my library
but I'm wondering is this is intended behaviour?
And if so, I'm sure it's been
around it by doing the destructuring in two steps in my library but
I'm wondering is this is intended behaviour?
And if so, I'm sure it's been discussed somewhere - maybe JIRA? - if someone
would be so kind as to point me to the ticke, that'd be much appreciated.
Cheers,
Leonardo Borges
}} '()] message)
IllegalArgumentException No value supplied for key: null
clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)
I worked around it by doing the destructuring in two steps in my library
but
I'm wondering is this is intended behaviour?
And if so, I'm sure it's been
1.4.1 release.
Several other bug fixes included in this update.
-David
On Friday, November 16, 2012 8:46:01 AM UTC-6, ffailla wrote:
Thank you David for looking into this so quickly. For now I am working
around this by not destructuring, but I look forward to the patch. Thanks.
-Frank
, November 16, 2012 8:46:01 AM UTC-6, ffailla wrote:
Thank you David for looking into this so quickly. For now I am working
around this by not destructuring, but I look forward to the patch. Thanks.
-Frank
On Thursday, November 15, 2012 7:41:39 PM UTC-5, dmiller wrote:
The difference
Thank you David for looking into this so quickly. For now I am working
around this by not destructuring, but I look forward to the patch. Thanks.
-Frank
On Thursday, November 15, 2012 7:41:39 PM UTC-5, dmiller wrote:
The difference is that the JVM version is correct and the CLR
1 - 100 of 306 matches
Mail list logo