Hi Stuart,
> I think the big strength of Clojure is how easy it is to integrate
> Java code. If you have some performance-critical code you can always
> drop down to Java. Certainly, performance is important to Clojure, but
> I think the assumption is that it will never compete with pure Java on
Thanks Chouser,
That workaround works nicely for now. I think though that this problem
can potentially be the source of many hard-to-find bugs though. ie..
like in my second example, the vector of ArrayLists.
--~--~-~--~~~---~--~~
You received this message because y
Hi Tim,
I appreciate your comments.
> It is possible to achieve this behavior explicitly if you really
> wanted to:
> (defn create-add-2 []
> (with-local-vars [x 1]
> (do
> (var-set x 1)
> (var-set x (inc @x))
> (let [z @x]
> (fn [y] (+ y z))
That's true. On
On Thu, Jan 8, 2009 at 2:07 PM, Achim Passen wrote:
>
> Hi all!
>
> I encountered some corner cases where overflow checking for "-"
> doesn't work as I would expect:
>
> user=> (- Integer/MAX_VALUE Integer/MIN_VALUE)
> -1
> user=> (- Long/MAX_VALUE Long/MIN_VALUE)
> -1
>
> The problem seems to be
On Fri, Jan 9, 2009 at 9:49 PM, CuppoJava wrote:
>
> After more experimenting, it seems like a potentially difficult bug to
> resolve. Clojure attempts to treat all numbers as objects, but in this
> case, the choice of whether a number is an object or a primitive
> affects which method is called.
On Thu, Jan 8, 2009 at 9:34 AM, Tomasz wrote:
>
> Hi.
>
> I'm just wondering wether it's a feature or a bug:
>
> (if (= (meta (with-meta [] {:test-key true}))
> (meta #^{:test-key true} []))
> "same"
> "not same")
>
> =>
>
> "not same"
>
> This behaviour is repeatable for empty lists, vec
Yes, this makes things much more clear -- thanks for all the insights.
On Jan 9, 10:03 pm, Chouser wrote:
> On Fri, Jan 9, 2009 at 9:27 PM, Greg Fodor wrote:
>
> > Ok, this makes sense to me now. So, correct me if I'm wrong, but is it
> > safe to say that when you see parentheses surrounding va
On Fri, Jan 9, 2009 at 9:08 PM, James Reeves wrote:
>
> On Jan 10, 12:22 am, wubbie wrote:
>> How can you add line numbers for each line printed from the file.
>> Without line number, I have this:
>>
>> (with-open [rdr (reader "executors.clj")]
>> (filter #(println %) (line-seq rdr)))
>
> I do
On Jan 10, 12:22 am, wubbie wrote:
> How can you add line numbers for each line printed from the file.
> Without line number, I have this:
>
> (with-open [rdr (reader "executors.clj")]
> (filter #(println %) (line-seq rdr)))
I don't believe there's a function to do this, but it's easy enough t
On Fri, Jan 9, 2009 at 9:27 PM, Greg Fodor wrote:
>
> Ok, this makes sense to me now. So, correct me if I'm wrong, but is it
> safe to say that when you see parentheses surrounding values in the
> REPL output, that indicates the presence of a sequence, not
> necessarily a list? Still a little bit
My (admittedly newbie) attempt:
(with-open [rdr (reader "executors.clj")]
(map (partial format "%d: %s") (iterate inc 1) (line-seq rdr)))
On Jan 9, 7:22 pm, wubbie wrote:
> Hi,
>
> How can you add line numbers for each line printed from the file.
> Without line number, I have this:
>
> (with-
After more experimenting, it seems like a potentially difficult bug to
resolve. Clojure attempts to treat all numbers as objects, but in this
case, the choice of whether a number is an object or a primitive
affects which method is called.
(let [temp [(java.util.ArrayList. ["foo"])]]
(.remove (f
Ok, this makes sense to me now. So, correct me if I'm wrong, but is it
safe to say that when you see parentheses surrounding values in the
REPL output, that indicates the presence of a sequence, not
necessarily a list? Still a little bit odd since one could almost
argue that if that's the case you
I just noticed that Clojure is reacting strangely to overloaded
methods which take a primitive argument.
I'm trying to use ArrayList#remove which is overloaded to both take an
integer and an Object argument. Clojure behaves differently in a let
binding compared to a def.
Correct Behavior:
(let [
I guess I'm having trouble understanding what you're getting it, the
way I'm interpreting it is that you want to have seqs represented
differently from lists when outputted at the REPL. Also, I'm not sure
if this is a point of confusion, but lazy sequences are different from
sequence. Basically,
Right, but the confusion stems from the fact that all sequences are
not lists. I might just be really confused, but there seems to be some
asymmetry:
=> (seq [1 2 3])
(1 2 3)
=> (seq '(1 2 3))
(1 2 3)
=> '(1 2 3)
(1 2 3)
=> [1 2 3]
[1 2 3]
It seems that the output in the first two is driven b
Right, what I was more pointing out is the fact that the printed
version of a sequence in the REPL is syntactically identical to that
of a list. Which, clearly for most intents and purposes is a great
representation in output for using the REPL while doing development.
However, for a newcomer part
Lists -are- sequences (except for the empty list).
On Jan 9, 8:32 pm, Greg Fodor wrote:
> Hey all, I am just picking up Clojure here for the first time, sorry
> about the relative newbie question. One thing I noticed is that the
> REPL prints out a sequence as a list, basically eval'ing rest un
A sequence evaluates its elements on demand. The REPL needs to
evaulate the elements in order to print them. You can control how
many elements are printed by changing *print-length*.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
Hey all, I am just picking up Clojure here for the first time, sorry
about the relative newbie question. One thing I noticed is that the
REPL prints out a sequence as a list, basically eval'ing rest until it
sees nil. This threw me off a bit when first learning the language in
the last day because
Hi,
How can you add line numbers for each line printed from the file.
Without line number, I have this:
(with-open [rdr (reader "executors.clj")]
(filter #(println %) (line-seq rdr)))
thanks
sun
--~--~-~--~~~---~--~~
You received this message because you are s
Funny, it's this concept that has drawn me into looking into clojure
more in the
last few days. I worked on a highly structured editor at intentional
software
for some time but at the time had little exposure to LISP.
I feel a modern JVM based LISP such as Clojure with full access to
Java drawing
Does anyone see what I am doing here. I am creating some SWT code.
(import '(org.eclipse.swt.widgets Display Shell Text Widget))
(import '(org.eclipse.swt.widgets Label Menu MenuItem Control))
(import '(org.eclipse.swt.widgets FileDialog MessageBox))
(defn create-menu-bar [sh]
(let [b
On Jan 8, 5:04 pm, Chouser wrote:
> On Tue, Jan 6, 2009 at 2:53 PM, rzeze...@gmail.com wrote:
>
> > On Jan 4, 6:05 pm, "Brian Doyle" wrote:
> >> Is there some place where all of these vars are defined? Is there some
> >> way
> >> programatically I can find
> >> them all? Thanks.
>
> > I'm b
Would someone mind posting an example of a parameterized query using
clojure.contrib.sql? There are examples in the source of non-
parameterized queries, and do-prepared is used to parameterize values
for inserts, but I can't seem to get my form quite right for a query.
thanks,
Greg
--~--~---
On Jan 9, 2009, at 4:04 PM, BerlinBrown wrote:
Is it better style to use the 'proxy'ing to create a class or to use
the gen-class approach.
There are limitations to proxying that make gen-class sometimes
necessary, but based on reading the group and only limited personal
experience, I ga
Is it better style to use the 'proxy'ing to create a class or to use
the gen-class approach.
-
(ns net.n01se.MyThread
(:gen-class
:extends "java.lang.Thread"
:constructors {[] [String]}
:init my-init
:state myState
:exposes-methods {getId getIdSuper}))
(defn -m
On 9 jan, 16:11, Stuart Sierra wrote:
> My recommendation would be to not write scripts at all. Instead, write
> a "-main" function for your namespace and launch your application at
> the Java command line in the usual way. In general, I think
> distributed libraries should never have top-level s
On 9 jan, 17:00, Rich Hickey wrote:
> Your initial presumption is not correct. All top-level expressions are
> compiled and will be evaluated on load. It is true that compilation
> supports a same-world model, and evaluates the file while compiling
> (in order to ensure declarations and macro def
Bill Clementson wrote:
> It appears to work ok for me with the following namespace declarations:
> (in-ns 'test)
> (ns test)
> (ns test (:use clojure.xml))
This no longer works for me because of the newline:
(ns foo.bar
(:require [clojure.contrib.sql :as sql]))
I simplified the regexp a
On Fri, Jan 9, 2009 at 1:47 PM, Tom Ayerst wrote:
> Time to bug Chouser again ;-)
>
> How's textjure coming along?
Vaporware is such an ugly word. :-P I've definitely had less time to
work on it over the last month or so than I was expecting.
Discussion from yesterday:
http://clojure-log.n01se
Time to bug Chouser again ;-)
How's textjure coming along?
2008/12/30 Chouser
>
> On Tue, Dec 30, 2008 at 1:24 AM, falcon wrote:
> >
> > How's textjure coming along?
>
> Not ready yet. :-/ Current sub-project: setting up sufficiently
> flexible system to handle vi-style keybindings.
>
> --C
I tested your patch with several more complicated namespace forms and
they all worked. Thanks for the fix!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@
On Fri, Jan 9, 2009 at 8:28 AM, Chouser wrote:
> So maybe leaving 'sort' undefined for lists makes sense. If you want
> them to sort like vectors, then use vectors!
But if the lists are nested within some aggregate structure, (e.g., in
the original postr's use case, the lists were the second el
On Fri, Jan 9, 2009 at 2:59 AM, Mark Engelberg wrote:
>
> Lexicographic ordering. Compare the first elements, if equal compare the
> rests.
Which is how vectors sort:
user=> (sort [[3 2 1] [1 2 3]])
([1 2 3] [3 2 1])
But vector grow on the right, like English words, so using
English-word-lik
On Thu, Jan 8, 2009 at 2:13 PM, Bill Clementson wrote:
> On Thu, Jan 8, 2009 at 11:57 AM, Zak Wilson wrote:
>>
>> Everything is fully up to date.
>>
>> The test works. Setting the ns with (ns test) works, but if I use a
>> more complex ns form like (ns test (:use clojure.xml)), it fails to
>> se
Thanks J. and Tim, and sorry for doing a shabby job searching the
archive before asking. :-)
Stuart
> http://groups.google.com/group/clojure/browse_thread/thread/82b88a7f6d9f993/0680a4f5dbf6ee61?lnk=gst&q=keyword#0680a4f5dbf6ee61
>
> RH: "The symbol String can name a class but the keyword :Str
On Jan 9, 2:00 am, lpetit wrote:
> On 9 jan, 07:54, lpetit wrote:
>
> > On 9 jan, 04:03, Stuart Sierra wrote:
> > > > Later on, if I call (load) (from a fresh clojure environment) from the
> > > > compiled classes, the top level (println)s are not executed, since not
> > > > compiled.
>
> > >
On Jan 8, 10:45 pm, Mark P wrote:
> I should also clarify one point. I am not "asking for this language
> feature" so much as "asking whether people have thought
> about it". There may (or may not) be good reasons for not offering
> such a language feature. I'm just wondering if it has been
>
My recommendation would be to not write scripts at all. Instead, write
a "-main" function for your namespace and launch your application at
the Java command line in the usual way. In general, I think
distributed libraries should never have top-level side effects.
-Stuart Sierra
On Jan 9, 2:00 am
On Jan 9, 6:05 am, Timothy Pratley wrote:
> Rich: You make the distinction that streams are not non-caching seqs.
> I read this as meaning that they wont implement ISeq, they will
> implement IStream, but conceptually they would be a non-caching
> "sequence" (in the English phrase sense, as opp
On Jan 9, 12:50 am, "Mark Engelberg" wrote:
> Oh, I mentioned this in my blog post, but perhaps it bears repating.
> If cycle, repeat, and replicate were implemented behind-the-scenes
> with LazySeq as opposed to LazyCons, they would still implement the
> promise of identical elements for separ
I just wrote some code where I need to construct a regular expression
from several strings. That meant I couldn't use #"expression", but
instead had to use (re-pattern (str part1 part2 part3)), right?
Currently re-pattern takes a single string. I think it would be
convenient if it took any number
On Jan 8, 11:22 pm, "Mark Engelberg" wrote:
> On Thu, Jan 8, 2009 at 5:55 AM, Rich Hickey wrote:
> > When you
> > ask for the nth element/rest, you get the identical item every time.
>
> I know this is nitpicking, but if this is really the promise that the
> seq abstraction is supposed to fulf
On Jan 9, 2009, at 13:18, Tzach wrote:
> The main function sudoku is recursive:
> 1. Getting a sudoku board as an input
> 2. Choosing the next empty (zero) cell to test, loop on all valid
> values, and call sudoku with the new board
> 3. When a solution (board with no zero values) is found: throw
http://groups.google.com/group/clojure/browse_thread/thread/82b88a7f6d9f993/0680a4f5dbf6ee61?lnk=gst&q=keyword#0680a4f5dbf6ee61
RH: "The symbol String can name a class but the keyword :String can't
As far as '.', that restriction has been relaxed. I'll try to touch
up
the docs for the next releas
On Fri, Jan 9, 2009 at 6:31 AM, Stuart Halloway
wrote:
>
> From the docs: "Keywords are like symbols, except ... They cannot
> contain '.' or name classes ..."
>
> What goes wrong with a keyword that contains "." or names a class?
> Nothing blows up immdiately at the REPL:
>
> user=> :java.lang.
> Most structures of this type would start life as a uniquely-referenced
> structure (either empty or a copy of an immutable), and have
> lots of mutations effectively applied to them in a safe environment,
> until they are ready to be "frozen" and released to the world as
> an immutable version o
Hi Clojure fans
My first attempt with Clojure is a Sudoku solver, and I'm fighting
with what are probably trivial problems (for a non newbie)
The main function sudoku is recursive:
1. Getting a sudoku board as an input
2. Choosing the next empty (zero) cell to test, loop on all valid
values, and
From the docs: "Keywords are like symbols, except ... They cannot
contain '.' or name classes ..."
What goes wrong with a keyword that contains "." or names a class?
Nothing blows up immdiately at the REPL:
user=> :java.lang.String
:java.lang.String
user=> :foo.bar
:foo.bar
--~--~
Rich: You make the distinction that streams are not non-caching seqs.
I read this as meaning that they wont implement ISeq, they will
implement IStream, but conceptually they would be a non-caching
"sequence" (in the English phrase sense, as opposed to seq in the
interface sense), and they should
51 matches
Mail list logo