you can use recur. it calls the fn/loop it's contained in with new
args. (so, with the updated array and queue)
On Dec 7, 8:19 pm, ajay wrote:
> Hi all,
>
> I am new to FP in general and I am trying to pick up Clojure. I am
> having trouble thinking in FP terms.
>
> I am trying to implement the D
can anyone explain why this doesn't work?
(defprotocol arrow
(>>> ([f g] [f g & fs]) "compose left to right"))
(extend clojure.lang.Fn
arrow
{:>>> (fn
([f g] #(g (f %)))
([f g & fs] (apply >>> (>>> f g) fs)))})
(>>> inc inc inc)
; gives this error:
; java.lang.IllegalA
i have updated the library to use arrows, rather than just functions.
(it still works with functions)
to make a new kind of arrow, you need to implement:
arr (creates an arrow from a function)
>>> (combines arrows left to right)
fst (makes arrow work on the first element of a vector, leaving the
.
>
> >>> is the same as (reverse (comp x)) right?
>
> &&& is called juxt
> *** - I believe this (map (juxt f-coll) coll)
>
> curry is called partial
>
> Still, good to see the comparison.
>
> On Oct 29, 10:20 am, harrison clarke wrote:
>
&g
rry wrote:
> Would love to see some examples usages of these
>
> On Sun, Oct 25, 2009 at 4:16 PM, harrison clarke wrote:
>
>
>
>
>
> > so i was using haskell, and the pointfree stuff is fun, so naturally i
> > had to implement some of it in clojure.
>
> >
maps could also be an option.
you can use vectors of ints as keys. (and you can stick dimensions and
such in there with keywords)
i'm not sure how that compares to nested vectors for perforance. you
have the overhead of the hash function, but you don't have any
nesting.
it's also pretty handy if
so i was using haskell, and the pointfree stuff is fun, so naturally i
had to implement some of it in clojure.
this is what i have so far. library and examples within:
http://github.com/hclarke/pointfree-clojure
it has >>>, &&&, ***, +++, |||, and others
they take functions as arguments and retu
you can't really use this as regular old mutable data.
if you store it somewhere, and then you change it, the original will
break.
i don't really see how you could use this in a non-functional way and
still
have it work at all.
like, you probably won't actually be let-binding them very often.
see
yep. a function f(n) is O(n) if there are constants c and n0 such that f(n)
<= c * n for all n >= n0.
sometimes you do care about the c and the n0, though.
On Sun, Dec 14, 2008 at 12:41 PM, levand wrote:
>
> Ah, ok... I would have assumed that would be labeled as O(2n). Didn't
> realize that was
ue, Dec 9, 2008 at 3:48 PM, Drew Olson <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 2:28 PM, Stephan Mühlstrasser <
> [EMAIL PROTECTED]> wrote:
>
>>
>> On Dec 9, 12:34 am, "harrison clarke" <[EMAIL PROTECTED]> wrote:
>> > you're k
you're keeping the head of the sequence, and thus all the elements between
the head and nth.
it's because you're using def, basically.
if you make a function to return the sequence, and pass the result directly
to nth, without let-binding it or anything, it should work.
--~--~-~--~~-
the same issue is there for sorted-map and sorted-set.
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, sen
did cond change syntax?
last i checked, it was
(cond (case) (expr)
(case) (expr)
)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojur
the hard part about implementing continuations in a language that doesn't
already support them is that you're trying to capture it from within.
with a delimited continuation, you're capturing it from the outside, so you
don't have that problem.
--~--~-~--~~~---~--~
another issue would be that your function call would have to be on one line.
(the nested ones could have multiple lines, since they'd be in parens)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To p
found the problem:
sorted-set doesn't play nice with longs.
the "fix" to my specific problem is to not square the primes when
adding new counters.
any way to change the comparator on a sorted set? i'd also like to use
lazy seq's as counters, and it doesn't liek that either.
--~--~-~--~--
i made a lazy prime number seive, and it seems to work for a while:
(defn natural [] (iterate #(+ % 1) 1))
(def primes
;;takes a sorted set of counters and a seq of numbers to filter
((fn sieve [in-counters checked]
;;first part of the cons is the first in said seq. hurray!
i was thinking that each stat would be an agent.
whatever boats your float, i guess. i'm probably not the person to go
to about idiomatic code. :V
user> (let [player {:str (agent 5)
:dex (agent 5)}
str (:str player)
dex (:dex player)]
(println @str @dex)
(send str +
> (send (:str player) #(+ % 1))
on second thought, this should be the same:
(send (:str player) + 1)
or:
(send (player :str) + 1)
if you use agents, just make sure you use await before dereferencing
them. could cause some issuses if you don't.
--~--~-~--~~~---~--~---
i think agents would be a better fit than refs.
as you said, you don't need transactions, since everything is sequential
anyway.
so whenever you need to change something, just send the change to the agent.
(send (:str player) #(+ % 1))
--~--~-~--~~~---~--~~
You r
20 matches
Mail list logo