On Jun 11, 3:42 pm, Chouser wrote:
> On Thu, Jun 11, 2009 at 3:03 PM, Adrian
>
>
>
> Cuthbertson wrote:
>
> > Here's a fuller example of similar techniques extracted from a working
> > program. It reads a file of lines and applies some transformations and
> > accumulates a vector of records whi
On Thu, Jun 11, 2009 at 3:03 PM, Adrian
Cuthbertson wrote:
>
> Here's a fuller example of similar techniques extracted from a working
> program. It reads a file of lines and applies some transformations and
> accumulates a vector of records which it finally returns;
>
> (defn some-fn
> "Read a fi
Adrian and David are suggesting how to work functionally, which is best when
appropriate. Berlin, if you really need state modified over time, Clojure
does this differently from most languages. Values never change, only
references to values and only in controlled ways. Maybe what you want is a
r
Here's a fuller example of similar techniques extracted from a working
program. It reads a file of lines and applies some transformations and
accumulates a vector of records which it finally returns;
(defn some-fn
"Read a file and return a vector of its records."
[fpath]
(let
[r (Buffer
Re-read your example - that should have been;
(let [updated-val (loop [updateable 0 line (.readline reader)]
(if (or (empty? line) (> line-num max-num))
(+ updateable (somefunc))
(recur (.readLine reader)]
(do-something-with updated-val))
I.e initialising updateable to 0.
On
You could do something like;
(let [updated-val (loop [updateable start-value line (.readline reader)]
(if (or (empty? line) (> line-num max-num))
(+ updateable (somefunc))
(recur (.readLine reader)]
(do-something with updated-val))
Rgds, Adrian.
On Thu, Jun 11, 2009 at 8:34
Why isn't the following satisfactory for your needs? get-value takes a value
returns a new value based on it. do-something can 'do something' to/with
this new value.
(defn get-value [start-value]
(loop [updateable start-value line (.readline reader)]
(if (or (empty? line) (> line-num max-num
On Jun 11, 12:16 pm, Daniel Lyons wrote:
> On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote:
>
>
>
> > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I
> > am using some pseudo code because I don't have a clojure solution yet.
>
> > SET UPDATEABLE_VALUE = 0
> > (loop [line (
On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote:
>
> I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I
> am using some pseudo code because I don't have a clojure solution yet.
>
> SET UPDATEABLE_VALUE = 0
> (loop [line (.readLine reader)]
> (if (or (empty? line) (> line-
Not totally clear what you are trying to accomplish, but would something
like the following work?
(defn get-value [start-value]
(loop [updateable start-value line (.readline reader)]
(if (or (empty? line) (> line-num max-num))
(+ updateable (somefunc))
(recur (.readLine reader)))
I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I
am using some pseudo code because I don't have a clojure solution yet.
SET UPDATEABLE_VALUE = 0
(loop [line (.readLine reader)]
(if (or (empty? line) (> line-num max-num))
SET UPDATEABLE_VALUE = UPDATEABLE_VALUE
11 matches
Mail list logo