The Clojure parser I'm writing needs to differentiate between nil and
the empty list. It should parse "[1 2 3]" and read that as [1 2 3],
and the same for lists, maps, and sets. If it parses "()" and reads
that nil, then it's not working correctly.
In addition, code in some other libraries I'm wri
clojure.lang.Cons
user=> (list? (list* 1 [2 3])) ; Danger
false
I'll just go back to using #(apply list %). But this is very weird: if
list* never returns lists (except when given a single non-empty list
argument), why call it list*? And why say in the doc that it returns
lists?
On J
@DeSeno: list*'s doc does indeed say that the last element will be
treated as a seq, but the beginning of the same doc definitely says
that list* returns a list. The doc is:
Creates a new list containing the items prepended to the rest, the
last of which will be treated as a sequence.
"The last
was pretty unexpected.
I thought list* was to list as vec is to vector.
On Jan 22, 2:55 pm, ataggart wrote:
> On Jan 22, 1:30 pm, samppi wrote:
>
> > This is not a big deal: it is a quibble with a weird and inconvenient
> > behavior of list*: when given an empty sequence, it ret
This is not a big deal: it is a quibble with a weird and inconvenient
behavior of list*: when given an empty sequence, it returns nil
instead of the empty list. Why is this? According to list*'s
documentation, list* should always return a list.
--
You received this message because you are subscri
Do you also want the binding to act like let's, with unpacking of
vectors and maps?
If so, there's no public function that I know of that's set apart for
doing this—are you trying to do this in a function or a macro? If
you're creating a macro, then it's easy: just splice the binding form
into a l
For those of you who are familiar with Clojure monads, please consider
the following problem. In the REPL log below, I define a monad parser-
m whose monadic values are parser functions (in fact, it's the same as
state-m, only with nil indicating failure) and a function rep+ that
creates a new rule
t pred) coll))
>
> And get the last entry of that
>
> user=>(last (take-until odd? [2 4 6 8 9 10 11]))
> 8
>
> It's based on take-while, so it's lazy.
>
> Sean
>
> On Dec 24, 1:34 pm, Chouser wrote:
>
>
>
> > On Thu, Dec 24, 2009 at 1:24
Excellent, thank you very much!
On Dec 24, 11:34 am, Chouser wrote:
> On Thu, Dec 24, 2009 at 1:24 PM, samppi wrote:
> > I'm having trouble with figuring out something. First, to get the
> > first element of a sequence so that (pred element) is false, you do
> > (first
I'm having trouble with figuring out something. First, to get the
first element of a sequence so that (pred element) is false, you do
(first (drop-while pred sequence)). This is lazy, and stops
immediately when the element is found.
Now, I want to get the element *right before* the element returne
I'm using a vector as a stack. I want to apply a function–let's call
it modify-element, one argument—to the elements from k to (- (count a-
vector) k).
Right now, I have something like (not tested yet):
(reduce #(update-in %1 [%2] modify-element) a-vector (range k (-
(count a-vector) k)))
Is th
, predicate-fn and recur-fn :
>
> > > (def b f1)
> > > (def c (comp f2 b))
> > > (def d (comp f3 c))
> > > (def e (comp f4 d))
> > > (def g (comp f5 c))
> > > (def h (comp f5 f2))
>
> > > (def return-fn e)
> >
I'm trying to rewrite a loop to use higher-level functions instead.
For pure functions f1, f2, f3, f4, f5, f6?, and f7, and a Clojure
object a0, how can one rewrite the following loop to use map, reduce,
etc.?
(loop [a a0]
(let [b (f1 a)
c (f2 b)
d (f3 c)
e (f4
If it's for side-effects, then using _ is fine, in my opinion—they're
nicely identifiable.
They're especially useful for inserting println calls for seeing the
value of something when I'm debugging; in fact, this is the primary
way I do debugging. I would say, though, that usually if you're going
That's incredible: that my big loop could be collapsed into such
little code. Thanks a lot; I'm still wrapping my brain around these
functions, but they're so awesome.
On Dec 6, 1:20 pm, ataggart wrote:
> On Dec 6, 11:28 am, samppi wrote:
>
>
>
>
>
>
I've read that loop/recur is less preferable to using higher-level
function calls like reduce and for and map, especially when chunked
seqs are implemented. But is can the loop below be rewritten to use
those functions instead? It's a loop that iterates over one vector and
changes both the vector a
Also, you should also consider simply using the seq function, which is
what you should use when you want just to evaluate a lazy sequence:
(str (seq (map identity [1 2 3])))
"(1 2 3)"
On Dec 6, 11:20 am, CuppoJava wrote:
> This is expected behavior.
>
> eg. (str (map identity [1 2 3]))
> returns
nage relations'
data internally: instead of a set of tuples/maps, a map of indexes to
tuples/maps. It'd probably be the fastest, but perhaps harder to
edit?)
On Dec 4, 4:37 pm, "Alex Osborne" wrote:
> samppi writes:
> > I want to create a little Clojure library that c
I want to create a little Clojure library that creates cached
relational systems in the style of Ben Moseley's "Out of the Tar
Pit" (http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf), which is
something that I think would serve me better than just nested maps for
something. I'm at the planning st
Dang. I forgot about reduce. Thanks a lot for the really quick answer!
On Nov 30, 3:45 pm, Martin DeMello wrote:
> On Tue, Dec 1, 2009 at 4:09 AM, samppi wrote:
> > The title says it all. Is there a nice, concise, Clojurey way to
> > convert a vector [a b c d] into [[[a b] c] d
The title says it all. Is there a nice, concise, Clojurey way to
convert a vector [a b c d] into [[[a b] c] d]? It's fine if the
vectors are sequences instead. I can't think of a way without a loop,
but I suspect there's a much shorter way.
--
You received this message because you are subscribed
uot;Failure"
object defined by deftype with the failed state's metadata attached to
it. Thank goodness that metadata doesn't affect equality.
On Nov 24, 1:37 am, Konrad Hinsen wrote:
> On 21 Nov 2009, at 06:31, samppi wrote:
>
> > And no matter what I do, I can't fulfil
I see; then that of course would be the reason. Thanks for the answer.
On Nov 23, 12:24 pm, Rich Hickey wrote:
> On Nov 23, 11:36 am, samppi wrote:
>
>
>
>
>
> > Variable-length arguments in protocols seem to be supported, but
> > there's just a weird, statef
Variable-length arguments in protocols seem to be supported, but
there's just a weird, stateful behavior. Look what happens when you
call foo first with one argument twice (it fails both times), then two
arguments (it succeeds), then one argument again (it succeeds now
too!). Is this a Clojure bug?
The following code contains an error, and I cannot figure out what it
is at all. When I run StateMeta's test once, the statement marked with
a comment above fails. When I run it again, it succeeds. This has been
causing very weird bugs in my code. I've replicated the behavior in
both a script and t
Ah, update-in is exactly what I need. Excellent, thank you.
On Nov 22, 2:38 pm, John Harrop wrote:
> On Sun, Nov 22, 2009 at 4:32 PM, samppi wrote:
> > Does a function that does this:
> > (vary coll :x fn-x, :y fn-y)
> > ; Equivalent to (assoc coll :x (fn-x (:x coll)),
Does a function that does this:
(vary coll :x fn-x, :y fn-y)
; Equivalent to (assoc coll :x (fn-x (:x coll)), :y (fn-y (:y
coll)))
exist in the core or contrib APIs?
I'm surprised that I can't find any. It's a very natural extension of
assoc. But if there really isn't any, is the code below th
tore metadata on the object representing failure. I'm sure I'll
figure something out.) Thanks for your help.
On Nov 22, 1:31 pm, jim wrote:
> Samppi,
>
> Good work on figuring that out. It's by working through those kinds of
> problems that you really learn about monads. I
Thanks for the help.
After working it out, I just figured out that the reason why the
second axiom isn't fulfilled by the m-zero above is this part in m-
bind:
((product-fn product) new-state))
product-fn, which in the second axiom's case is (fn [x] m-zero), gets
called
ts axioms. This makes using :when clauses in domacro
work incorrectly for reasons I can't explain. What is this monad's
proper value of m-zero?
On Nov 21, 8:28 am, jim wrote:
> Samppi,
>
> Here's a parser-m monad I did.
>
> (defmonad parser-m
>
I'm writing a maybe/state monad using clojure.contrib.monads. I've
gotten by fine with using just (state-t maybe-m), but now I need
different behavior:
I need a monad that behaves precisely like (state-t maybe-m), except
that when a monadic value mv is called on a state s and fails, (mv s)
return
Is there a more elegant way to phrase this?
(defn- inc-index
"Increments the :index val in the givens state's metadata."
[state]
(vary-meta state assoc :index (inc (:index ^state
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to th
This is wonderful, wonderful, wonderful. It makes my work with FnParse
so much easier.
Question: are the general mechanisms for accessing and setting fields
their keywords and assoc respectively:
(deftype Bar [a b c d e])
(def b (Bar 1 2 3 4 5))
(:c b)
(def c (assoc b :e 2))
Does (:c b) an
t and second for both cases.
>
> On Nov 11, 9:52 am, samppi wrote:
>
>
>
> > Clojure 1.1.0-alpha-SNAPSHOT
> > user=> (conj (first {1 2}) 3)
> > [1 2 3]
> > user=> (conj {1 2} [2 5])
> > {2 5, 1 2}
> > user=> (key (first {1 2}))
> &
Clojure 1.1.0-alpha-SNAPSHOT
user=> (conj (first {1 2}) 3)
[1 2 3]
user=> (conj {1 2} [2 5])
{2 5, 1 2}
user=> (key (first {1 2}))
1
user=> (key [1 2])
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be
cast to java.util.Map$Entry (NO_SOURCE_FILE:0)
In all respects but one, two-
I use clojure.contrib.def/defvar a lot. It's really useful for adding
docstrings to non-function vars. But I've been tripped up by the same
mistake a lot now—I keep expecting the docstring to go after the
initial value, because that would be consistent with defn, defmacro,
and defmulti.
Here are
Well, that's how the key itself is useful. What I'm wondering is why
it is useful for the key to be passed to the watching function every
time it's called.
On Oct 26, 1:13 pm, pmf wrote:
> On Oct 26, 8:12 pm, samppi wrote:
>
> > According to the docs, the function pa
According to the docs, the function passed into an add-watch call
receives four arguments. Its first argument is a "key". This key seems
to be the same key as the key passed into the add-watch call, and so
would always be the same, for the same ref and function. What is the
point of this argument
Here's something that I've been confused about for a long time:
I've read many, many times that binding allows you to give to vars
"thread-specific values", and that vars have a "thread-global value"
too. I think that I understand how vars and binding work, but I don't
understand how binding is n
Excellent; this is perfect. I wonder why I didn't find it when I
searched the docs...thanks a lot, though.
On Oct 25, 3:16 pm, Phil Hagelberg wrote:
> samppi writes:
> > with-meta's behavior is annoying for me. I often have something like
> > this:
>
> > (de
with-meta's behavior is annoying for me. I often have something like
this:
(defn a [blah] (with-meta blah {:type ::incredible}))
(defn b [foo] (with-meta (a foo) {::b 2}))
I'd like ^(b []) to be {:type ::incredible, ::b 2}. But with-meta
overwrites the metadata from a completely. Is there a
ymbol? (tree-seq seq? rest rel-rep
>
> - James
>
> On Oct 24, 9:55 pm, samppi wrote:
>
>
>
> > I suspect the code below can be improved. The function returns the set
> > of all symbols inside a list-tree that are not at the beginning of a
> > list. Is there
I suspect the code below can be improved. The function returns the set
of all symbols inside a list-tree that are not at the beginning of a
list. Is there a way to make the code more compact or faster?
(with-test
(defn- find-dependencies
[rel-rep]
(cond
(list? rel-rep)
(le
Thanks a lot! I didn't know about the existence of gensym. This will
help a lot.
On Oct 23, 9:54 pm, John Harrop wrote:
> On Sat, Oct 24, 2009 at 12:19 AM, samppi wrote:
> > user=> (defmacro b [form]
> > (let [processed-form (a form rec#)]
> >
I'm trying to create a macro called "procedure" so that:
(procedure (and _x (pos? _y)))
expands to
(fn [rec#] (and (:x rec#) (pos? (:y rec#
I'm stuck because I can't figure out a way to generate a symbol
outside. I'm a newbie at macros, so I don't know if there's a better
way around this:
Are private multis possible? I notice that clojure.contrib.def does
not have a defmulti-, which doesn't bode well, but it's still worth a
question at the mailing list.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "C
That is indeed nice. Thanks for the code; I guess I don't really have
to settle for #(%) after all.
@RandyHudson: apply would work, but it's pretty slow, and not worth
switching from #(%).
On Oct 21, 11:49 pm, Timothy Pratley wrote:
> On Oct 22, 3:22 pm, John Harrop wrote:
>
> > user=> (map ca
op wrote:
> On Wed, Oct 21, 2009 at 7:49 PM, samppi wrote:
> > Is there a standard function that takes one argument and calls it?
> > That is, the function equivalent to #(%). Or is that the best idiom
> > there is?
>
> #(%) is only four characters. Calling apply wi
nil
user=> (time (dotimes [_ 500] (apply a)))
"Elapsed time: 0.923 msecs"
nil
On Oct 21, 5:04 pm, James Reeves wrote:
> apply
>
> On Oct 22, 12:49 am, samppi wrote:
>
>
>
> > Is there a standard function that takes one argument and calls it?
> >
Is there a standard function that takes one argument and calls it?
That is, the function equivalent to #(%). Or is that the best idiom
there is?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post
Don't forget about the third piece of the puzzle, #() (and fn).
Whenever I need to create a function using ->, I just do #(-> % ...).
It's about as much typing as (comp ...).
Personally, I can go either way—I just kind of wish that there was a
consistent practice for the placement of the most imp
Ah, it's a shame that there's no devoted command to commenting. Thanks
for that command, though. Maybe I should record a macro for it...
On Oct 14, 6:47 pm, Richard Newman wrote:
> > I realize that this isn't directly related to Clojure proper, but I'm
> > learning Vim while using VimClojure, an
I realize that this isn't directly related to Clojure proper, but I'm
learning Vim while using VimClojure, and I think this is probably the
best place to ask—is there a command to comment all the lines through
a motion with semicolons?
--~--~-~--~~~---~--~~
You rece
d write the function slightly differently
>
> (defn transform-map [f a-map] ...)
>
> The f implies a mapping operation. pred implies a filter operation.
>
> On Oct 10, 8:40 pm, samppi wrote:
>
>
>
> > Is there a function in the standard libraries that's equ
Is there a function in the standard libraries that's equivalent to
this:
(defn transform-map [pred a-map]
(into {} (map (comp pred val) a-map)))
(is (= {:a 4, :b 3}
(transform-map inc {:a 3, :b 2})))
It's not like I can't write this myself; I use this a lot, though, and
I'm w
I want to do this:
(defn a ...)
(cache a) ; or (cache #'a) or (cache 'a); it doesn't matter to me
...instead of this:
(def a (memoize (fn ...)))
That way, it separates the concern of what a does from the
optimization I'm doing on it. Now, I'm kind of stuck; how should I do
it?
(defn c
I've heard a lot that Google App Engine's use of many JVMs makes
Clojure refs, etc. less useful than they are on one JVM. I'm curious—
what are the consequences of using a ref normally in Google App
Engine? How would it be broken? Would each JVM, invisibly, each store
a different value for the ref
Why does metadata not work on conj-ed sequences?
Clojure 1.0.0-
user=> (def a (with-meta [1 2 3] {:a 2}))
#'user/a
user=> ^(conj a 4)
{:a 2}
user=> (def b (with-meta (seq [1 2 3]) {:a 2}))
#'user/b
user=> ^b
{:a 2}
user=> ^(conj b 4)
nil
--~--~-~--~~~---~--~~
You
That's perfect. Thanks a lot, everyone.
On Sep 20, 11:35 am, Jarkko Oranen wrote:
> > > (def b #^{:b 2} (quote (1 2 3)))
>
> > ... and #^{} applies read-time to the following *form* rather than the
> > value they evaluate to, so that is why neither (list ...) nor (quote
> > ...) work.
>
> Yep. #
I was messing with the REPL when I found this happens:
Clojure 1.0.0-
user=> (def a #^{:a 5} [1 2 3])
#'user/a
user=> ^a
{:a 5}
user=> (def b #^{:b 2} '(1 2 3))
#'user/b
user=> ^b
{:line 3}
user=> (def c (with-meta '(1 2 3) {:c 0}))
#'user/c
user=> ^c
{:c 0}
What's going on with that {:line 3}?
That's great! Thanks a lot for the explanation.
On Aug 25, 2:58 pm, Richard Newman wrote:
> Incidentally, you can find this stuff out by reading the source, if
> you know where to look. It's a reader macro, so LispReader.java is the
> best place to start. Look for the metachar '=', which cro
#= is a real Clojure reader macro. It often shows up when using *print-
dup*:
Clojure 1.0.0-
user=> (binding [*print-dup* true] (println {:a 3, :b 2}))
#=(clojure.lang.PersistentArrayMap/create {:a 3, :b 2})
nil
user=> #=(clojure.lang.PersistentArrayMap/create {:a 3, :b 2})
{:b 2, :a 3}
It's und
I just discovered something cool that might seem obvious to some
people but is, as as I can tell, undocumented and caught me totally by
surprise. It's well known that the reader resolves ::something
into :the-current-namespace/something. But what I found out is that if
you use require to alias a n
Wonderful; I totally didn't know about zipmap. I've been using into
and map this whole time. Was it added right before Clojure 1.0? It
seems to be a lot faster than using into:
Clojure 1.0.0-
user=> (time (into {} (for [i [1 2 3]] [i (+ 3 i)])) )
"Elapsed time: 0.705 msecs"
{3 6, 2 5, 1 4}
user=>
I'm trying to make a decision in a parser library between using
regular maps as states (containing a sequence of remaining tokens, as
well as other info) vs. using metadata maps attached to the sequence
of remaining tokens. In other words:
{:remainder [\r \e \m], :index 3, :line 5, :column 2}
For me, I'd like it if the core functions had the "data" as the first
argument, but have a special function—I can't come up with a better
name than "partial-2"—so that (partial-2 function opt1 opt2 opt3) is
equivalent to (fn [data] (function data opt1 opt2 opt3)). That way, I
could do things like
Why doesn't this work?
Clojure 1.0.0-
user=> (declare aaa)
#'user/aaa
user=> (var (symbol "aaa"))
java.lang.ClassCastException: clojure.lang.PersistentList cannot be
cast to clojure.lang.Symbol (NO_SOURCE_FILE:2)
user=> (var 'aaa)
java.lang.ClassCastException: clojure.lang.Cons cannot be cast to
Plus, this doesn't depend on a how the compiler implements or
> > optimizes names. It could be that in the future clojure will want to
> > use a different representation internally than maps for symbol->value
> > translation.
>
> > -V
>
> > On Aug 9, 11
Excellent, excellent. But I'm wondering, is it planned (or feasible)
for structmap transients to be supported too? I often use and "modify"
protean structmaps in loops, and I'd love to know if the concept of
transients can be applied to them.
On Aug 6, 4:53 am, Rich Hickey wrote:
> On Aug 5, 10:
Great, thanks. Is clojure.lang.Var/pushThreadBindings a public,
supported part of the API? Can I use it without fear of suddenly
dropped support?
On Aug 6, 10:56 pm, Meikel Brandmeyer wrote:
> Hi,
>
> On Aug 7, 7:12 am, samppi wrote:
>
> > So is this possible without arcane
I have about six variables that are often rebound together using
binding; these variables are used to access and set data in a state
object (whose type is of the user's choice). These variables' values
(the accessors and setters) are often used together.
I'd like to be able to bundle these values
I'm trying to make a macro my-macro so that the last statement in:
(def my-map {:a 2})
(defn process-a-map [arg] ...)
; Turns maps into corresponding vectors.
; (process-a-map my-map) returns ['*foo* :blah].
(my-macro a-map ; Last statement
(do-something))
expands to:
(bind
Also, identity works too:
#(identity "foo") ; equivalent to (fn [] "foo")
On Aug 2, 10:04 am, Meikel Brandmeyer wrote:
> Hi,
>
> Am 02.08.2009 um 17:56 schrieb Sean Devlin:
>
> > 1. Use quote
>
> > #(quote "foo")
>
> For this approach I would recommend `do`:
>
> (let [x 5] #(quote x)) ; *meeep
or Clojure to be able to create a controller layer
> from any defined set of functions with certain metadata on them.
> That's the current direction I'm thinking of taking the idea.
>
> If you are interested, I can ship over the Netbeans project of it all.
>
> Sam Griff
I haven't tried JavaFX much myself, but has anyone tried or thought
about using Clojure to manage the logic and data of a JavaFX
application yet? What limitations would there be, other than having to
compile its Clojure code?
--~--~-~--~~~---~--~~
You received this
I've just discovered the clojure.templates library [1], and I'm
wondering what's the difference between its function and that of
regular functions:
(apply-template '[x] '(+ x x) '[2])
((fn [x] (+ x x)) 2)
[1]
http://github.com/stuarthalloway/clojure/blob/6ee62ec1d88383e1caadb8b93a19fd389c001
Awesome, thanks for the quick answer. I think that it'd be a useful
thing to add to seq-utils or something. :)
On Jul 17, 1:41 pm, Mark Engelberg wrote:
> On Fri, Jul 17, 2009 at 1:32 PM, samppi wrote:
>
> > Is there a function in clojure.core or clojure.contrib so that:
>
Is there a function in clojure.core or clojure.contrib so that:
(and (mystery-fn '(a b c d) '(a b))
(not (mystery-fn '(a b c d) '(a b d
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
T
3:55 am, Wilson MacGyver wrote:
>
>
>
> > Thanks for the tip on looking at clojure.contrib. I keep forgetting to
> > check there.
>
> > On Jul 5, 2009, at 4:20 PM, samppi wrote:
>
> > > If you need a JSON parser, there's already a good one included w
Excellent. This will be a lifesaver—thanks a lot.
On Jul 9, 8:21 am, Chouser wrote:
> On Jul 8, 11:53 pm, samppi wrote:
>
> > In clojure.contrib.def, I'd love to have a defmemo macro that acts
> > just like defn, only with memoize. I'm planning to change a lot of
In clojure.contrib.def, I'd love to have a defmemo macro that acts
just like defn, only with memoize. I'm planning to change a lot of
functions to use memoize, and I'm not looking forward to changing
nice, clean defns with docstrings to (def {:doc docstring} function
(memoize (fn ...)))s. Would th
need to parse a bunch on JSON files on Monday :) good
> work
>
> Sent from my iPhone
>
> On Jul 4, 2009, at 3:16 PM, samppi wrote:
>
>
>
>
>
> > I'm pleased to announce FnParse, a monadic functional parsing library
> > for Clojure, half a year in the m
I'm pleased to announce FnParse, a monadic functional parsing library
for Clojure, half a year in the making. I started on FnParse in
December as my first Clojure project, and now it has matured to
something that I believe is very and immediately useful. Currently,
I'm writing a YAML parser using
t; (def st (create-struct :a :b :c))
> (keys (struct st))
> (:a :b :c)
>
> -Adrian.
>
>
>
> On Tue, Jun 30, 2009 at 12:14 AM, samppi wrote:
>
> > Wonderful. Thanks for the answer.
>
> > On Jun 29, 2:47 pm, Rich Hickey wrote:
> > > On Jun 29, 4:59
Wonderful. Thanks for the answer.
On Jun 29, 2:47 pm, Rich Hickey wrote:
> On Jun 29, 4:59 pm, samppi wrote:
>
> > clojure.xml/parse returns a PersistentStructMap. Is there a way to
> > refer to its struct template? I wish to create accessors for its keys,
> > s
clojure.xml/parse returns a PersistentStructMap. Is there a way to
refer to its struct template? I wish to create accessors for its keys,
such as :tag, :attrs, and :content, with the accessor function for
speed.
--~--~-~--~~~---~--~~
You received this message becaus
Wonderful. Thanks for the answers.
On Jun 28, 12:39 pm, "Stephen C. Gilardi" wrote:
> On Jun 28, 2009, at 3:03 PM, samppi wrote:
>
> > I use Clojure's classes a lot in my multimethods. Is there any way to
> > abbreviate them; that
I use Clojure's classes a lot in my multimethods. Is there any way to
abbreviate them; that is, is there a method to refer to
clojure.lang.APersistentList as APersistentList? I've tried (use
'clojure.lang) and (require ['clojure.lang :as 'c]), but neither seem
to work.
--~--~-~--~~
Thanks for the replies. Mr. Brandmeyer's solution is exactly what I
needed; I don't really want to change rep+'s return value from a
vector, which would sort of break backwards compatibility.
On Jun 26, 8:25 am, Meikel Brandmeyer wrote:
> Hi,
>
> Am 26.06.2009 um 17:09 s
Thanks for the replies, everyone.
@Mr. Gilardi, this is for a one-time only thing. I have a function,
called rep*, that builds up a vector from left to right. Another,
separate function, called rep+, calls rep*, but it needs to slip in an
element at the vector's beginning.
I'm considering changi
Currently, if I want to do this: (mystery-fn [0 1 2 3 4] -1) -> [-1 0
1 2 3 4]), I use vec and cons: (vec (cons a-vec obj-to-insert)). Is
there a better way?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" gr
Thanks for the answers. I need to generate symbols to distinguish them
from strings in a parser. It seems, then, that it's better to use
symbols rather than keywords in this case.
On Jun 24, 10:52 am, "Stephen C. Gilardi" wrote:
> On Jun 24, 2009, at 1:30 PM, Four of Seventeen wrote:
>
>
>
> > O
Are keywords and symbols garbage-collected? If I generated a lot of
keywords or symbols, put them into a collection, and then removed
them, would they disappear and free up space? I'm wondering if they're
similar to Ruby symbols, which are never garbage collected.
--~--~-~--~~
Thanks everyone. They all seem to take less time than the filter way
too.
On Jun 23, 4:05 pm, Cosmin Stejerean wrote:
> On Tue, Jun 23, 2009 at 5:09 PM, samppi wrote:
>
> > The idiom (into {} coll-of-entries) is often used to create a map from
> > a collection of entries or
The idiom (into {} coll-of-entries) is often used to create a map from
a collection of entries or two-sized vectors. But what if I want to do
something like this:
(mystery-fn [[:a 1] [:b 3] [:b 5] [:c 1]]) ; returns {:a [1], :b [3
5], :c [1]})
The only way I can think of doing this is with a com
I'd love to be able to do this:
(defstruct person-s :name :gender)
(def name-a (accessor person-s :name))
(def gender-a (accessor person-s :gender))
(def person-1 (struct person-s "Jane" :female))
(let [{name name-a, gender gender-a, :as person} person-1]
(println name gender person))
...ins
Why does using a list with into and a map throw an exception, while
using a vector is fine?
Clojure 1.0.0-
user=> (def a (list :a 1))
#'user/a
user=> (into {} [a])
java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to
java.util.Map$Entry (NO_SOURCE_FILE:0)
user=> (def b [:a 1])
#'u
I want to create a function that takes a variable of an error-kit
error type and inserts it into a handle statement, but when I try, I
get a strange error. What does the error mean, and is there a way to
pass a variable error type into a handle statement without resorting
to macros?
Clojure 1.0.0
That works perfectly. I forgot about macroexpand-1...but I also didn't
think that the (1 2 3) list would be evaluated using 1 as a function
too.
Thanks both of you for the great help.
On May 12, 8:33 am, "J. McConnell" wrote:
> On Tue, May 12, 2009 at 11:22 AM, samppi wrote
maybe-m (m-seq ~...@xs)))
#'user/c
user=> (c 1 2 3)
java.lang.IllegalArgumentException: Wrong number of args passed to:
monads$m-PLUS-m-seq-PLUS-m (NO_SOURCE_FILE:0)
Trying both ~ and ~@ in this case gets me two kinds of errors.
Thanks for your patient help.
On May 12, 7:59 am, Konrad Hinsen wrote:
>
1 - 100 of 211 matches
Mail list logo