Hello,
Am 07.01.2009 um 17:44 schrieb Meikel Brandmeyer:
Please find attached another patch going for IRef instead
of Var directly. And without the other cruft.
Another update in sync with updated issue #8.
Sincerely
Meikel
issue-8b.diff
Description: Binary data
smime.p7s
On 11.01.2009, at 08:56, Tzach wrote:
Following your good advice, I also update the next-cell function to
work in a lazy way instead of sorting the values of the entire board.
Good idea!
(defn next-cell [board]
return the next potential cell to set, and the valid alternatives
(first
On Jan 11, 6:32 am, Nick Vogel voge...@gmail.com wrote:
Ok, first of all, here's how I translated that python code:
(defn msort [myList]
(if ( (count myList) 1)
(let [l1 (first myList) l2 (second myList)]
(recur (concat (drop 2 myList) (my-merge l1 l2
(first myList)))
Hi,
I'm just learning Clojure too, so I don't have much to add to what
everyone else has said, but here's my crack at a full implenentation
of merge-sort in Clojure. I'm sure that there is plenty of room for
improvement (especially wrt. the merge function) but in case it's
helpful, here it is:
Hello,
If you like eclipse and would like to see where clojuredev (eclipse
plugin) is right now, you can give a quick look at the current state
of clojuredev by trying to immediately install it via the update site
link :
http://clojure-dev.googlecode.com/svn/updatesite/
Still not ready for
that looks interesting, except it is missing the part where you take
the original list and make it into a list of lists using list
comprehension. That works in python and clojure for me ... the so
far so good part. If the recur were to do that repeatedly, the
algorithm would get messed up.
great. I wondered about that, too! thanks.
On Jan 11, 7:27 am, James Reeves weavejes...@googlemail.com wrote:
On Jan 11, 6:32 am, Nick Vogel voge...@gmail.com wrote:
Ok, first of all, here's how I translated that python code:
(defn msort [myList]
(if ( (count myList) 1)
(let
I'm trying to follow. Can you explain in pseudo code? That's
impressive that it follows the classic approach on persistent data
structures . . .. from what I can tell. You successively divide the
list in halves of halves of halves. Then the lists of size 1 are
merged together as the stack
great. will do.
On Jan 11, 9:14 am, lpetit laurent.pe...@gmail.com wrote:
Hello,
If you like eclipse and would like to see where clojuredev (eclipse
plugin) is right now, you can give a quick look at the current state
of clojuredev by trying to immediately install it via the update site
On Jan 2, 2009, at 2:21 AM, budu wrote:
Hi, I was experimenting with clojure-contrib's sql features and found
that there wasn't any update-values function. I've written my own and
I'm sharing it here:
(defn update-values [table where column-names values]
Update columns of a table with
refs seem silly in this context! Now I REALLY have to get my head
wrapped around clojure. sooo I only have one thread, but I have
to do a dosync? Why can this whole function just work in a thread
agnostic way? It's a local variable! If a thread calls it, then a
thread should own the
On Sun, Jan 11, 2009 at 10:50 AM, e evier...@gmail.com wrote:
refs seem silly in this context! Now I REALLY have to get my head
wrapped around clojure. sooo I only have one thread, but I have
to do a dosync? Why can this whole function just work in a thread
agnostic way? It's a local
Thinking functionally is hard when you're used to programming
imperatively. So instead of leaping straight into Clojure, lets stick
with Python for the time being.
So let's take your Python code:
def msort(someList):
myList = [[x] for x in someList]
while len(myList) 1:
l1 =
this seemed like a clean, nice way to merge to sorted lists into one
sorted list. I'm not getting clojure syntax, it seems:
(defn listmerge [l1 l2]
(let [l1first (first l1) l2first (first l2)]
(if (= l1first nil) l2)
(if (= l2first nil) l1)
(if ( l1first l2first)
(cons
Hi,
I'm just wondering if there's a clever way of creating a new map from
an existing map of map of maps.. with a key deep inside altered.
ie. given this map: {:a {:b {:c {:d 3
i want to create a new map, with the value at :d increased by 5.
I wrote a macro to do this, but it's quite ugly.
that's awesome, and I hope it helps others, too. Thanks for starting
with python.
This gets to my question perfectly. Why is your code my-list
(rest (rest my-list)) legal?
I wouldn't have even thought to try that because, in essence, you are
changing my-list. I mean, I know how persistence
On Jan 11, 5:53 pm, e evier...@gmail.com wrote:
this seemed like a clean, nice way to merge to sorted lists into one
sorted list. I'm not getting clojure syntax, it seems:
(defn listmerge [l1 l2]
(let [l1first (first l1) l2first (first l2)]
(if (= l1first nil) l2)
(if (= l2first
this seemed like a clean, nice way to merge to sorted lists into one
sorted list. I'm not getting clojure syntax, it seems:
(defn listmerge [l1 l2]
(let [l1first (first l1) l2first (first l2)]
(if (= l1first nil) l2)
(if (= l2first nil) l1)
(if ( l1first l2first)
(cons
I think you can just use the update-in function like:
1:1 user= (def m {:a {:b {:c {:d 3)
#'user/m
1:2 user= (update-in m [:a :b :c :d] - 5)
{:a {:b {:c {:d -2
On Sun, Jan 11, 2009 at 11:08 AM, CuppoJava patrickli_2...@hotmail.comwrote:
Hi,
I'm just wondering if there's a clever
i see that my-list (rest (rest my-list)) is in a let section. That
seems like the scope would mean we are talking about a different my-
list.
On Jan 11, 1:19 pm, e evier...@gmail.com wrote:
that's awesome, and I hope it helps others, too. Thanks for starting
with python.
This gets to my
i see that my-list (rest (rest my-list)) is in a let section. That
seems like the scope would mean we are talking about a different my-
list.
Yes, it is a new my-list with a smaller scope. I didn't search for the
expression (rest (rest my-list)) before my earlier response.
That's exactly what I was looking for.
Thank you Brian.
--~--~-~--~~~---~--~~
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,
On Jan 11, 6:19 pm, e evier...@gmail.com wrote:
This gets to my question perfectly. Why is your code my-list
(rest (rest my-list)) legal?
Because you're not actually changing anything.
In theory, the let form can be derived from anonymous functions. So
(let [x y] ...) is the same as ((fn
if it has tighter scope, then I don't understand why you don't have an
infinite loop. The nested my-list that you redefined should have
nothing to do with the my-list that you are doing the 'rest' check
on. (rest my-list) should always be non-nil because the inner let is
operating on a
oh. I missed the recur my-list in your answer. So we still don't
have an iterative solution. Recursion should never be necessary. I
agree that it simplifies things sometimes and you can use it when you
are stuck. . . . .but no need to push a whole stack frame for such a
simple problem, I
ahhh I see. That makes sense. So it's not like procedural
programming. You could see what I was trying to understand.
I didn't want case/swtich semantics. like the (cond) or if, else if
style. I was trying to return at the first true thing, but it doesn't
work like that. it always gets
On Jan 11, 7:09 pm, e evier...@gmail.com wrote:
if it has tighter scope, then I don't understand why you don't have an
infinite loop. The nested my-list that you redefined should have
nothing to do with the my-list that you are doing the 'rest' check
on.
That's what the loop/recur form
On Jan 11, 7:19 pm, e evier...@gmail.com wrote:
oh. I missed the recur my-list in your answer. So we still don't
have an iterative solution. Recursion should never be necessary. I
agree that it simplifies things sometimes and you can use it when you
are stuck. . . . .but no need to push a
thanks for your patience. I think I'm starting to get it.
Interesting discussion on tail recursion. Add a lot of depth to what
Rich was talking about. Really smart work-around!
On Jan 11, 2:50 pm, James Reeves weavejes...@googlemail.com wrote:
On Jan 11, 7:19 pm, e evier...@gmail.com wrote:
While trying to run clojure on JNode I noticed that some dead code in
the ASM generated bytecode of clojure makes it fail because it
confuses the JIT.
One example of the problem can be seen with javap:
javap -c clojure.core\$last__2780
Result (relevant part) :
public java.lang.Object
Is it possible to access a constant inside a public static class which
is defined inside a public interface?
For example:
package com.rabbitmq.client;
import java.io.IOException;
[...skipped...]
public interface AMQP
{
public static class PROTOCOL {
public static final int MAJOR =
Let's say I have a function, alt:
(defn alt [ functions]
(fn [tokens]
(some #(% tokens) functions)))
It creates a function from a bunch of sub-functions that accepts one
collection of tokens and figures out which sub-function returns a true
value when the tokens are plugged into it.
Is
On Sun, Jan 11, 2009 at 3:30 PM, wal valebe...@gmail.com wrote:
Is it possible to access a constant inside a public static class which
is defined inside a public interface?
For example:
package com.rabbitmq.client;
import java.io.IOException;
[...skipped...]
public interface AMQP
{
some is already lazy, so you may not need to change anything at
all. You might also be able to use filter, which will not do
anything until you consume the output sequence.
-Stuart Sierra
On Jan 11, 4:44 pm, samppi rbysam...@gmail.com wrote:
Let's say I have a function, alt:
(defn alt [
The problem is that even though some and filter are lazy, alt is
still not, so calling (alt (sub-function1 c) ...) in the meta-meta-
function still evaluates (sub-function1 c), etc. It could be shown in
the REPL:
Clojure
user= (defn alt [ functions]
(fn [tokens]
(some #(% tokens)
One use I've found for - (though there are others I haven't come to
appreciate yet) is when I have something like:
(f1 (f2 (f3 (f4 x
which can be re-written as
(- x f4 f3 f2 f1)
I find the latter expression easier to read.
Kev
On Dec 30 2008, 2:49 pm, wubbie sunj...@gmail.com wrote:
Very
I've also found this useful for accessing members in nested maps. For
example:
(let [me {:person {:name {:first Mark
:last Triggs}
:email mark.h.tri...@gmail.com}}]
(- me :person :name :first))
= Mark
On Jan 12, 1:04 pm, kkw
Hi,
For the purposes of testing another function (not discussed here), I
wrote a function to generate random strings. This is what I ended up
with after some trial and error.
(defn generate-data [size maxlength]
; Returns a collection of 'size random strings, each at most
'maxlength
Why aren't all sequences callable, i.e. why don't they all implement
IFn? I'd like to use lists like this sometimes.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send email
thread should own the memory that's created. Each thread should have
its own asynchronous stack to push local variables onto that no one
else is allowed to see.
Just for the record, Clojure does support local variable that behave
exactly as you would expect them:
(with-local-vars [x 3]
I have had similar problems with enclojure. But having gone through
similar IDE pain working in Ruby on Rails, the Netbeans support ended
up being way ahead of most IDEs, so I have hopes that enclojure will
get there in time. (My biggest annoyance? The fact that you can't
open existing code as
On Sun, Jan 11, 2009 at 9:38 PM, Ethan Herdrick herdr...@gmail.com wrote:
Why aren't all sequences callable, i.e. why don't they all implement
IFn? I'd like to use lists like this sometimes.
When you call maps and vectors, it acts as if you're calling 'get'.
But 'get' doesn't do anything
Incidentally, if you want a language with an editor built in, why not
look at Smalltalk? I vaguely recall that was a big part of the
original language concept. I haven't ever played with it myself, but
the most popular current flavour seems to be Squeak:
http://www.squeak.org/
Smalltalk
I might look at the JEdit plugin though - JEdit is nice, for simple
editing, which might be good enough for me for now.
I similarly haven't had time to relearn emacs and have used jedit quite
sucessfully with jedit-mode. I keep one or more terminal window tabs open
each with a REPL launched with
I can't imagine this idea will be met warmly, but I have a suggestion.
It requires ending maps and vectors as functions of keys. Instead,
make the first argument to a collection be a function which is mapped
to across the collection. Any additional arguments are passed to the
function on
here's a good explanation:
http://groups.google.com/group/clojure/browse_thread/thread/3c22b35f079e0de6/95fc0b334ab77c1f
I wasn't thinking about closures since I've only recently even learned what
they are. I actually don't know if it will ever occur to me to use them,
but it sounds like they
I have recently found out about Clojure and am
rather impressed. I am seriously considering
whether Clojure is a viable language for use at
work. The main stumbling block would be if
performance (both speed and memory) turns out
to be insufficent. I currently use C++, but I'd love
to be able
is the @ symbol the same as a var-get . . . or is that and atom. Your
sentence about atoms was very compound. I'm not sure if you said that you
used an atom but you didn't have to . . . .or you didn't use an atom because
it wasnt necessary . . . . or you did use an atom because it was necessary
Bear with the trials and tribulations (of grokking
functional/clojure). It takes a few weeks of trying things out,
absorbing the documentation and group archives, watching the group
posts and then suddenly there are one or two aha moments and then
the flood gates open! When you've crossed the
My point was that it is not a missing capability,
Say you want to accumulate some changes, in this case sum odd numbers:
In C++ someone might write this:
int x = 0;
for (int i=0; i100; i++) {
if ( i%2==1 ) x+=i;
}
However in Clojure you have a choice:
(reduce + (range 1 100 2))
Or you could
I'm sure you are right. I'm going to have to be good at making these
arguments with my coworkers (or find somewhere else to work, maybe? :) ) so
I appreciate the depth people are going to.
One of my next bouts of confusion is going to come from trying to figure out
what's already done. Like I
Hi Emeka,
Sorry for the slow response. I don't get that message with the latest
clojure, clojure-contrib, and clj-record. (load-file just returns
nil.)
What version of clojure are you running? Do you have the base
directory of clj-record on your classpath?
Also, that file just contains the
I can't speak for clojure, so I'm interested in seeing how people who can
will answer.
There's so much to consider. I've heard Haskell is getting faster and has
(or will have) parallel programming under the scenes (automatically doing
independent parts of operations). There are other fast
On 12 янв, 01:01, Chouser chou...@gmail.com wrote:
On Sun, Jan 11, 2009 at 3:30 PM, wal valebe...@gmail.com wrote:
Is it possible to access a constant inside a public static class which
is defined inside a public interface?
For example:
package com.rabbitmq.client;
import
is the @ symbol the same as a var-get . . . or is that an atom.
@ is a reader macro that translates to (deref ) which works on vars,
atoms, refs, agents.
and yes is interchangeable with var-get.
Your sentence about atoms was very compound. I'm not sure if you said that
you
used an atom but
looks like an awesome book. will check it out more. thanks.
On Mon, Jan 12, 2009 at 1:06 AM, Josip Gracin josip.gra...@gmail.comwrote:
On Sun, Jan 11, 2009 at 10:33 PM, e evier...@gmail.com wrote:
thanks for your patience. I think I'm starting to get it.
Interesting discussion on tail
I'm not planning on programming like this, but just to try to finish this up
. . . .it's still not working. I get an odd error when I actually try to
sort something that iSeq doesn't work on integers. I have no idea where to
still the (first my-list) at the end so it returns, too. No need to
a few fixes. still not there yet.
(defn elisort [toSort]
(with-local-vars [my-list (for [x toSort] [x])]
(while (rest (var-get my-list))
(let [[l1 l2 my-list2] (var-get my-list)]
(var-set my-list (concat my-list2 (listmerge [l1] [l2] (first
(var-get my-list)
On Mon,
On Sun, Jan 11, 2009 at 9:35 PM, GS gsincl...@gmail.com wrote:
Hi,
For the purposes of testing another function (not discussed here), I
wrote a function to generate random strings. This is what I ended up
with after some trial and error.
(defn generate-data [size maxlength]
;
59 matches
Mail list logo