I was thinking about how things like function or variable renaming are
complicated by lisps macros. That it's almost impossible to track the
scope of anything, since 2 symbols near each other might mean
completely different things after macro expansion.
So I came up with an algorithm that *might* w
Well, a more important matter, this example in the documentation of
atom is wrong!
The recursive calls will not be memoized if called like that. Running
this code clearly shows:
(defn memoize [f]
(let [mem (atom {})]
(fn [& args]
(if-let [e (find @mem args)]
(val e)
(le
Arrays are mutable, seqs immutable. Clojure ='s compares immutable
structures by value, and mutable structures by reference (for the
objects that it is aware of, for others it just prays that they have a
resoanable equals method). This behaviour is described in the very
interisting Henry Baker's eg
On 8 mar, 23:22, Michał Marczyk wrote:
> I'd suggest a vector instead; they're countable in constant time and
> you can use, say, conj and rest for add to end of queue / eject from
> front of queue.
Conj adds to the end of a vector in constant time, but rest will not
return another vector, but a
;Simple example
(defn fib1 [n]
(if (or (= 0 n) (= 1 n))
1
(+ (fib1 (- n 1))
(fib1 (- n 2)
(defn-memo fib2 [n]
(if (or (= 0 n) (= 1 n))
1
(+ (fib2 (- n 1))
(fib2 (- n 2)
;workaround for this problem
(declare aux-fib)
(defn-memo fib3 [n]
(if (or (= 0 n) (=
What he said is basically right, only instead of list it's called
vector. Not sure if vector branching is 64 or 32.
On 10 fev, 15:42, Paul Mooser wrote:
> I ran across this on reddit this morning, and thought people on the
> group might find it interesting:
>
> http://docs.google.com/viewer?url=
Would it be possible to create an implementation of delay and lazy-seq
that didn't use fn to delay evaluation, or atleast captured dynamic
variables?
(delay (+ x 3)) reasonable semantics in current clojure (let [x x]
(delay (+ x 3)))
(delay (fn [y] (+ x y))) semantics should be the same it alread
It's one thing to try to protect the programmer from accidentally
shooting himself on the foot, but I don't think it is as necessary for
a language to prevent him from doing it on purpose.
On 8 nov, 02:59, John Harrop wrote:
> user=> (def q 'G__723)
> #'user/q
> user=> (def r (gensym))
> #'user/
Lua's solution to long strings is having multiple levels of
delimiters. [[ is the opening delimiter of level 0, and is closed
by ]] . [=[ is of level 1, closed by ]=] , etc.
No matter what string you are trying to represent, it can always be
literally represented that way.
On 12 out, 17:25, Greg
If efficiency is really an issue (if it's not just use apply), how
about using a macro for doing the dirty work of writing the direct
function application for you?
On 20 maio, 19:44, CuppoJava wrote:
> Thanks a lot for that really detailed analysis Stephen.
> I do find "apply" very convenient in
So, I was wondering if anyone had implemented the amb operator in
Clojure, so I decided to give it a try. This is my first Clojure
program bigger then 5 lines, the code still needs ALOT of work, it is
ugly as hell atm, but I think it kind of works. (Yes, I know, it's
very easy to bug it, its just
Laziness is the rule only on sequence operations.
On Apr 2, 11:34 pm, Sean wrote:
> Thanks for the response everyone! I was able to get it working. If I
> understand what everyone is saying, the following statement is true:
>
> In Clojure, laziness is the rule not the exception.
--~--~---
12 matches
Mail list logo