Yes, dynamic vars do not exist in CLJS, so naturally binding doesn't work
as you would expect.
On Thu, Mar 16, 2017 at 11:36 AM, Christian Weilbach <
whitesp...@polyc0l0r.net> wrote:
> You cannot do so in cljs though:
> http://dev.clojure.org/jira/browse/CLJS-1634
>
> Just in case you expect to w
You cannot do so in cljs though:
http://dev.clojure.org/jira/browse/CLJS-1634
Just in case you expect to write cross-platform code with dynamic bindings.
Am 16.03.2017 um 01:01 schrieb Timothy Baldridge:
> Yes, that should work fine, do your tests confirm otherwise? Also if
> you're not doing a
Yes, that should work fine, do your tests confirm otherwise? Also if you're
not doing a recur there's no reason to use `go-loop` you can just use `go`.
On Wed, Mar 15, 2017 at 4:44 PM, Eran Levi wrote:
> Hi,
> can I bind variables, same as I do for threads, for go routines, to be
> local only fo
Hi,
can I bind variables, same as I do for threads, for go routines, to be
local only for a particular go routine, and if I can't, how would you mimic
this behavior ?
(defn print-stuff [s]
(println s))
(go-loop []
(binding [*out* (clojure.java.io/writer "foo.txt")]
(print-stuff)))
(
Usually it's better to create a sentinel (Object.) to lock on to avoid sharing
it. (Well really it's best to avoid locking at all and use Clojure state
constructs if you can.)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, se
The problem here is that you are splicing in obj when there is no need to.
You actually want your generated code to refer to obj. So just
(defmacro mac1 [& body] `(locking obj ~@body))
is fine.
dennis' solution will work too, but it will work almost accidentally? All
blank maps evaluate to the s
I think the reason is in macroexpand-1 result:
user=> (macroexpand-1 '(mac1 1))
(clojure.core/locking # 1)
It's not a valid form to be read and eval by clojure reader,the object form
can't be parsed.
If define obj to be a map {}, it works fine:
user=> (def obj {})
#'user/obj
user=> (mac1 1)
1
u
user=> (def obj (Object.))
#'user/obj
user=> (defmacro mac1 [& body] `(locking ~obj ~@body))
#'user/mac1
user=> (mac1 nil)
CompilerException java.lang.RuntimeException: Can't embed object in code,
maybe print-dup not defined: java.lang.Object@2a747a37,
compiling:(NO_SOURCE_PATH:1:1)
Why am I ge
2014-07-09 4:19 GMT+02:00 Bob Hutchison :
>
> On Jul 8, 2014, at 7:08 PM, Cecil Westerhof
> wrote:
>
> 2014-07-08 23:11 GMT+02:00 Bob Hutchison :
>
>>
>> On Jul 8, 2014, at 9:40 AM, Cecil Westerhof
>> wrote:
>>
>> > In Clojure you can define a local constant with let, but I need a
>> variable (I
On Jul 8, 2014, at 7:08 PM, Cecil Westerhof wrote:
> 2014-07-08 23:11 GMT+02:00 Bob Hutchison :
>
> On Jul 8, 2014, at 9:40 AM, Cecil Westerhof wrote:
>
> > In Clojure you can define a local constant with let, but I need a variable
> > (I think).
> >
> > I want to do the following. I have a
2014-07-08 23:11 GMT+02:00 Bob Hutchison :
>
> On Jul 8, 2014, at 9:40 AM, Cecil Westerhof
> wrote:
>
> > In Clojure you can define a local constant with let, but I need a
> variable (I think).
> >
> > I want to do the following. I have a function that checks several
> things. Every time an error
On Jul 8, 2014, at 9:40 AM, Cecil Westerhof wrote:
> In Clojure you can define a local constant with let, but I need a variable (I
> think).
>
> I want to do the following. I have a function that checks several things.
> Every time an error is found I want to set the variable errors to:
>
>
> Also, just a matter of style, but it's customary to leave closing parens
>> at the end of a line, rather than by themselves on their own line.
>>
>
> I do that also, but when I am editing I put them on there own line,
> because in this way changes are faster. When I am satisfied, I merge them.
2014-07-08 18:14 GMT+02:00 John Gabriele :
> On Tuesday, July 8, 2014 11:38:42 AM UTC-4, Cecil Westerhof wrote:
>>
>>
>>
>>
>> 2014-07-08 16:55 GMT+02:00 John Gabriele :
>>
>> On Tuesday, July 8, 2014 9:40:54 AM UTC-4, Cecil Westerhof wrote:
In Clojure you can define a local constant wit
On Tuesday, July 8, 2014 11:38:42 AM UTC-4, Cecil Westerhof wrote:
>
>
>
>
> 2014-07-08 16:55 GMT+02:00 John Gabriele >:
>
>> On Tuesday, July 8, 2014 9:40:54 AM UTC-4, Cecil Westerhof wrote:
>>>
>>> In Clojure you can define a local constant with let, but I need a
>>> variable (I think).
>>>
>>>
On Tue, Jul 8, 2014 at 11:38 AM, Cecil Westerhof wrote:
> I al-ready tried something along those lines:
> (defn error-in-datastruct-p []
> (let [errors (atom ())]
>(if (= (count objects) (count *object-locations*))
>(map (fn [x]
> (println x)
>
2014-07-08 16:55 GMT+02:00 John Gabriele :
> On Tuesday, July 8, 2014 9:40:54 AM UTC-4, Cecil Westerhof wrote:
>>
>> In Clojure you can define a local constant with let, but I need a
>> variable (I think).
>>
>> I want to do the following. I have a function that checks several things.
>> Every tim
On Tuesday, July 8, 2014 9:40:54 AM UTC-4, Cecil Westerhof wrote:
>
> In Clojure you can define a local constant with let, but I need a variable
> (I think).
>
> I want to do the following. I have a function that checks several things.
> Every time an error is found I want to set the variable err
you can make that variable "error" as an Agent and change it asynchronously
or as a Ref if you want the change synchronously. other part of the code
remains same.
On Tuesday, 8 July 2014 19:10:54 UTC+5:30, Cecil Westerhof wrote:
>
> In Clojure you can define a local constant with let, but I need
On 8 July 2014 at 17:40:49, Cecil Westerhof (cldwester...@gmail.com) wrote:
> > In Clojure you can define a local constant with let, but I need
> a variable (I think).
They are not constants. Locals can be "overwritten" but their data structures
are immutable (by default).
> I want to do the f
In Clojure you can define a local constant with let, but I need a variable
(I think).
I want to do the following. I have a function that checks several things.
Every time an error is found I want to set the variable errors to:
(concat errors new-error)
Is this possible? Or is there a better w
Phew! Thank you. That did it. I did need to add the nil to each nth
statement, but this helps.
(defn process-file
"Process csv file and prints a column in every row"
[file-name]
(let [data (slurp file-name)
rows (parse-csv data)
read-map (zipmap (map #(nth % 11 nil) rows) (ma
;2011-06-05 23:00:00","61016","SMITH","E & J",
> > 80581200,43,0,75,"2011-06-06 06:00:01","61016"
> > 33891773,411200,"2011-06-05 23:00:00","610159000","COMMONER","A",
> >
On Thu, Jun 30, 2011 at 4:30 PM, octopusgrabbus
wrote:
> Thanks for answering.
>
> I want to create a map of this output:
>
> PremiseID Reading
> 61016 101100
> 610159000 411200
> 610158000 133100
> 610157000 239400
> nil nil
>
> produced by this function
>
> (defn process-file
> "Process csv
uot;,
> > 80581200,43,0,75,"2011-06-06 06:00:01","61016"
> > 33891773,411200,"2011-06-05 23:00:00","610159000","COMMONER","A",
> > 80598726,43,0,75,"2011-06-06 06:00:01","610159000"
> > 3389188
quot;DecodeType","LoadDateLocal","PremiseID"
> > 33891715,101100,"2011-06-05 23:00:00","61016","SMITH","E & J",
> > 80581200,43,0,75,"2011-06-06 06:00:01","61016"
> > 33891773,411
6-06 06:00:01","610159000"
> 33891887,133100,"2011-06-05 23:00:00","610158000","JONES","J & M",
> 80581189,43,0,75,"2011-06-06 06:00:01","610158000"
> 33891825,239400,"2011-06-05 23:00:00","610157000"
t;61016"
33891773,411200,"2011-06-05 23:00:00","610159000","COMMONER","A",
80598726,43,0,75,"2011-06-06 06:00:01","610159000"
33891887,133100,"2011-06-05 23:00:00","610158000","JONES","J & M",
80
Not sure what you mean by 'row of vectors', and 'break up each row'.
On Thu, Jun 30, 2011 at 3:20 PM, octopusgrabbus wrote:
> If I have rows of vectors, such as the return from clojure-csv\parse-
> csv
>
> ["a" 1 "b" 2 "c" 3 "d" 4]
> ["e" 5 "f" 6 "g" 7 "h" 8]
>
> How can I break up each row?
>
>
If I have rows of vectors, such as the return from clojure-csv\parse-
csv
["a" 1 "b" 2 "c" 3 "d" 4]
["e" 5 "f" 6 "g" 7 "h" 8]
How can I break up each row?
I've tried doseq in the let statement, but get an error.
On Jun 30, 2:27 pm, octopusgrabbus wrote:
> Thanks. That did it.
>
> On Jun 30, 1
Thanks. That did it.
On Jun 30, 1:22 pm, Mark Rathwell wrote:
> One way would be:
>
> (defn map-func
> "test map function"
> []
> (let [mtr-seq (vector "a" 1 "b" 2 "c" 3 "d" 4)
> read-map (apply hash-map mtr-seq)
> (println read-map)))
>
> On Thu, Jun 30, 2011 at 1:09 P
One way would be:
(defn map-func
"test map function"
[]
(let [mtr-seq (vector "a" 1 "b" 2 "c" 3 "d" 4)
read-map (apply hash-map mtr-seq)
(println read-map)))
On Thu, Jun 30, 2011 at 1:09 PM, octopusgrabbus wrote:
>
> Given this function
>
> (defn map-func
>"test m
Given this function
(defn map-func
"test map function"
[]
(let [mtr-seq (vector "a" 1 "b" 2 "c" 3 "d" 4)
read-map ()
(println read-map)))
I want to load read-map with the keys and values from mtr-seq.
Eventually, this data is going to be from the return from pars
33 matches
Mail list logo