2012/6/8 Andy L andy.coolw...@gmail.com
Is there a simple test for sequable?
seq?
--
Cédric
--
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
Note that posts from new members are
Hi Andy,
On Fri, Jun 8, 2012 at 1:44 PM, Andy L andy.coolw...@gmail.com wrote:
On 06/07/2012 09:22 PM, Ambrose Bonnaire-Sergeant wrote:
Every Seqable is not Sequential.
(sequential? {:a 1}) = false
Is there a simple test for sequable?
No. I assume you mean seqable.
If it did exist, it
I wrote a quick sort function in clojure, but it runs extremely slow.
Sometimes, if the input collection grows lager, it may even overflow the
stack?
Anything wrong with my code?
(defn qsort [coll]
(if (= (count coll) 1)
coll
(let [pivot (last coll)
head-half (filter #( %
Hi,
this will be simplified tremenduously when there is a Seqable protocol. Then
satisfies? will do the job.
I'm still thinking when I ever needed seqable?, though.
Kind regards
Meikel
-Ursprüngliche Nachricht-
Von: Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com
An:
2012/6/8 Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com
No. I assume you mean seqable.
If it did exist, it would look something like:
Is there a simple test for sequable?
Oh ok, I don't get the difference between seq and seqable..
Btw, i found this (
2012/6/8 Cédric Pineau cedric.pin...@gmail.com
2012/6/8 Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com
No. I assume you mean seqable.
If it did exist, it would look something like:
Is there a simple test for sequable?
Oh ok, I don't get the difference between seq and seqable..
I also read the sort function in clojure.core, but it make confused.
01 (defn sort
02 Returns a sorted sequence of the items in coll. If no comparator is
03 supplied, uses compare. comparator must
04 implement java.util.Comparator.
05 {:added 1.0
06:static true}
07 ([coll]
last and drop-last are slow operations on seqs, and no matter what you pass
in for the initial input, once you hit the recursive calls, you're passing
in seqs (because that's what filter produces). Try first and rest.
--
You received this message because you are subscribed to the Google
Groups
Another advantage to choosing the first element as a pivot is that you can
use destructuring:
(defn qsort [[pivot coll]]
(if coll)
On 8 June 2012 08:44, Mark Engelberg mark.engelb...@gmail.com wrote:
last and drop-last are slow operations on seqs, and no matter what you
pass in for the
I glanced at the contents and it looks like this is a cool thing that I'm
looking for. I will spend some time on it. Thank you Ken.
BTW, how can I view the second link (ending with .pamphlet) in a browser? I
tried it in Chrome but it just gave me a plain text without any format.
在
Stack-overflows in quicksort can mean that you are hitting the worst
case of this algorithm complexity.
(Meaning that you are sorting an array already sorted in one direction
or the other.
In this situation, the size of the recursive call are n - 1 and 0,
instead of being roughly n/2 for both
Note that the whole point of the real quicksort is to sort in place
with very good constants. In contrast, the commonly encountered
functional quicksort-lookalike traverses its input twice, allocates
two extra lists / seqs, then appends their sorted versions after
recursive calls. Ultimately it
On Thursday, June 7, 2012 1:53:30 PM UTC-4, Tom Hume wrote:
Hi
I'm trying to generate a sequence which corresponds to a breadth-first
search of a very wide, deep tree... and I'm hitting memory problems when I
go too far along the sequence. Having asked around on the IRC channel and
The second link is just a Latex source used to generate that pdf :)
Marek.
On Friday, June 8, 2012 11:10:19 AM UTC+2, jaime wrote:
I glanced at the contents and it looks like this is a cool thing that I'm
looking for. I will spend some time on it. Thank you Ken.
BTW, how can I view the
On Jun 8, 2012 3:18 AM, Cédric Pineau cedric.pin...@gmail.com wrote:
(defn seqable?
More modernly, this function can be found in core.incubator.
--
Stephen Compall
Greetings from sunny Appleton!
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To
You are welcome. Markus answered your question clearly I think, but
it may be instructive to view
http://youtu.be/mDlzE9yy1mk
which I should have just included in my original email.
This is Tim Daly demonstrating his process for literate programming
with Clojure by making a couple of edits to
(dorun (take 2000 (add-layer)))
take holds on to the head, because that is what it returns. Try changing
take to drop.
Take is lazy though, and dorun should drop the head, so that shouldn't be a
problem.
The problem here is not an holding onto the head issue. Lots of memory is
being
On Jun 8, 2012, at 2:21 AM, Cédric Pineau wrote:
2012/6/8 Cédric Pineau cedric.pin...@gmail.com
2012/6/8 Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com
No. I assume you mean seqable.
If it did exist, it would look something like:
Is there a simple test for sequable?
Oh ok,
Hi Ambrose,
On Fri, Jun 8, 2012 at 12:22 AM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
On Fri, Jun 8, 2012 at 12:11 PM, Tim Visher tim.vis...@gmail.com wrote:
2. While I would very much expect the type test (coll? seq?) to return
false on a string, I would _not_ expect the
Hello all,
I have the code below:
(def data
'(a b c c b a))
(for [value data] (hash-map id (.indexOf data value) value value))
That gives me the output:
({value a, id 0} {value b, id 1} {value c, id 2} {value c,
id 0} {value b, id 1} {value a, id 2})
but I need the following output:
You probably just want map-indexed...
Sent from my iPhone
On Jun 8, 2012, at 9:24 AM, Christian Guimaraes cguimaraes...@gmail.com wrote:
Hello all,
I have the code below:
(def data
'(a b c c b a))
(for [value data] (hash-map id (.indexOf data value) value value))
That gives me
(map #(hash-map :v %1 :id %2) '(a b c c b a) (range))
= ({:v a, :id 0} {:v b, :id 1} {:v c, :id 2} {:v c, :id 3} {:v b, :id
4} {:v a, :id 5})
/k
On Fri, Jun 8, 2012 at 3:31 PM, Jay Fields j...@jayfields.com wrote:
You probably just want map-indexed...
Sent from my iPhone
On Jun 8, 2012,
Thanks David. Could you recommend any other types of search, or a different
algorithm entirely, which might give me the same output in a sequence?
On Fri, Jun 8, 2012 at 1:29 PM, David Powell djpow...@djpowell.net wrote:
(dorun (take 2000 (add-layer)))
take holds on to the head, because
Hello,
I'm a beginner with Clojure and trying some basic stuff.
I'm actually working on a simple function which would replace the nth
element of a vector.
I'm using this function
(def ids-in-use (ref [1 2 3]))
(defn update-vector [v tid]
(assoc v tid 10))
(update-ids-in-use [2])
The problem
Nope, that doesn't make any difference; if something's keeping hold of the
head, it isn't the take:
= (first (drop 1999 (add-ch)))
OutOfMemoryError Java heap space clojure.lang.RT.cons (RT.java:552)
= (first (drop 1999 (add-layer)))
OutOfMemoryError Java heap space
Are you able to go to billions of items with the first version? I'm going
to be using this to work with truly vast sequences, so if there's any sort
of memory issue with the approach, I would expect it to be exposed at some
point - given that I can only throw finite amounts of memory at this.
Hello caffe and Yang Dong.
Here is my fold-right.
(defn fold-right [f s coll]
((reduce (fn [acc x] #(acc (f x %))) identity coll) s))
; (fold-right - 1 '(3 1 4))
; - ((fn [y3]
; ((fn [y2]
; ((fn [y1] (identity (- 3 y1)))
;(- 1 y2)))
; (- 4 y3)))
; 1)
Has anyone written a function minimizer in Clojure (or in Java)? I want
something like Octave's fminunc [0], where I can pass in a function and a
parameter list and find the parameters that minimize the function. Anyone
know of one?
[0]
I would love to have a version of doseq that works like map (similar to
each in other dynamic languages). In other words, instead of (doseq [log
logs] (println log)), I would say something like (each println logs).
Is there a built-in Clojure method that works like this?
--
You received this
The ants demo is definitely dated. It's not terrible, but the code could
use some polishing/simplifying using newer additions to the language.
-S
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
(map-indexed #(hash-map id %1 value %2) '(a b c))
or, if you don't want to use #()
(map-indexed (comp (partial zipmap [id value]) list) '(a b c))
On Fri, Jun 8, 2012 at 9:33 AM, Kevin Ilchmann Jørgensen
kijm...@gmail.comwrote:
(map #(hash-map :v %1 :id %2) '(a b c c b a) (range))
= ({:v a,
Seems like a fairly specialized function. No harm in including it where
it's needed, but does it need to go in clojure.string?
-S
--
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
Note that
I wouldn't mind seeing more in clojure.string. e.g. daserize, underscore,
pascal-case, camel-case
On Fri, Jun 8, 2012 at 9:46 AM, Stuart Sierra
the.stuart.sie...@gmail.comwrote:
Seems like a fairly specialized function. No harm in including it where
it's needed, but does it need to go in
Can you post a standalone example that doesn't require seesaw? Otherwise
it's hard to reproduce the problem.
If the problem is class visibility on the EDT, there are a couple of
possiblities:
1. Bind *use-context-classloader* to false in your event handler. This
might work.
2. Have the event
Combine map with dorun and you get the same effect:
(dorun (map println logs))
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/dorun
Allen
On Thu, Jun 7, 2012 at 11:32 PM, David Jacobs da...@wit.io wrote:
I would love to have a version of doseq that works like map
On Fri, Jun 8, 2012 at 9:54 AM, Allen Johnson akjohnso...@gmail.com wrote:
Combine map with dorun and you get the same effect:
(dorun (map println logs))
http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/dorun
Allen
On Thu, Jun 7, 2012 at 11:32 PM, David Jacobs
I'm not sure why it hangs, but my guess is that your actions are throwing
exceptions, breaking the loop and preventing the SynchronousQueue from ever
being filled.
By the way, the `time` you're measuring will dominated by `pprint`, not
your actual test.
-S
--
You received this message
There will be further releases of ClojureScript One.
As we work on ClojureScript projects for clients, we are learning a lot
about what works well and what doesn't. In the future, we will use what we
have learned to make improvements to ClojureScript One.
We also plan to move some of the
On Fri, Jun 8, 2012 at 12:30 AM, David Jacobs da...@wit.io wrote:
Has anyone written a function minimizer in Clojure (or in Java)? I want
something like Octave's fminunc [0], where I can pass in a function and a
parameter list and find the parameters that minimize the function. Anyone
know of
Hello fellow Clojurians,
I've started building an extendible board-game engine (chess/checkers at
the moment) and I'm facing a few problems...Let me explain...
For checkers I'd like to represent the board as a list of 31 positions.
Of course there has to be a mapping from the 1d list to a
Nevermind guys,
I took my eyes off the screen for 5 min. and it hit me!!! We have
'assoc' and it works on vectors!
I guess something like this should work...
(defn build-board [pieces]
(loop [nb (vector (repeat 32 nil))
p pieces]
(when (empty? p) (seq nb)
(recur (assoc nb
Marginalia v0.7.1 Release Notes
===
Marginalia is an ultra-lightweight literate programming tool for Clojure
and ClojureScript inspired by [docco](http://jashkenas.github.com/docco/)*.
To get a quick look at what the output looks like, [visit the official
Marginalia
On Jun 8, 2012, at 8:49 AM, Jay Fields wrote:
I wouldn't mind seeing more in clojure.string. e.g. daserize, underscore,
pascal-case, camel-case
+1
-
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com,
Whatever we do let's make sure we think about how to make it available in all
Clojure dialects.
Stu
On Jun 8, 2012, at 8:49 AM, Jay Fields wrote:
I wouldn't mind seeing more in clojure.string. e.g. daserize, underscore,
pascal-case, camel-case
+1
-
Brian Marick, Artisanal
Thank you all.
map-indexed will resolve my problem.
Christian
On Fri, Jun 8, 2012 at 2:46 PM, Jay Fields j...@jayfields.com wrote:
(map-indexed #(hash-map id %1 value %2) '(a b c))
or, if you don't want to use #()
(map-indexed (comp (partial zipmap [id value]) list) '(a b c))
On Fri,
+1
On Jun 8, 2012 6:54 PM, Stuart Halloway stuart.hallo...@gmail.com wrote:
Whatever we do let's make sure we think about how to make it available in
all Clojure dialects.
Stu
On Jun 8, 2012, at 8:49 AM, Jay Fields wrote:
I wouldn't mind seeing more in clojure.string. e.g. daserize,
Stuart Halloway wrote:
Whatever we do let's make sure we think about how to make it available in
all Clojure dialects.
Yes. When it comes to adding stuff to clojure.string, I'd like to focus
less on adding single-purpose functions like dasherize and more on
making sure that it's possible to
I created a tutorial explaining what the thrush - and - operator is.
https://github.com/ftravers/PublicDocumentation/blob/master/clojure-thrush.md
My tutorials are aimed at people who appreciate VERY explicit explanations,
which I think there is a bit of a gap among current internet available
On Jun 8, 2012, at 10:58 AM, Stuart Sierra wrote:
Stuart Halloway wrote:
Whatever we do let's make sure we think about how to make it available in
all Clojure dialects.
Yes. When it comes to adding stuff to clojure.string, I'd like to focus
less on adding single-purpose functions like
Well, I'm the dumbest person ever.
Here's the solution:
(if-match [(and ?c (contains? *chars* c)) Trip] c)
On Jun 7, 4:48 pm, JvJ kfjwhee...@gmail.com wrote:
Hi,
I've recently started using the matchure library for pattern matching
(https://github.com/dcolthorp/matchure).
Basically, I'd
On Fri, Jun 8, 2012 at 2:13 PM, Andy Fingerhut andy.finger...@gmail.com wrote:
Are you concerned that there are differences in regex implementations between
host platforms?
Slightly.
Or are you hoping that someone develops a portable-between-Clojure-hosts
regex implementation and adds that
Using Clojure 1.4.0, I'm inspecting the classloader stack my software
is running with... and have at times noticed numerous layered
DynamicClassLoader instances:
(defn classloader-parents [loader]
(when loader
(lazy-seq (cons loader
(classloader-parents (.getParent
Hello. Thank you for sparing your time for my proposal.
There are many negative votes for the proposal and the main doubt is
do you need to make them in closure.string?
My opinion is, perhaps I don't but I'm unsure until reading your replies.
At first I wrote some codes to improve
I've had a couple ClojureScript performance optimization insights recently
that has brought core.logic (running on V8) within a couple milliseconds of
the performance of miniKanren running on Racket. zebrao can now be solved
in ~13ms.
At this point I think the only thing that can make core.logic
Hi,
What is the best way to implement require-from-string?
Ex:
# require-from-string words like require but accepts namespaces as strings.
(def namespace-from-user (ask-user))
(require-from-string namespace-from-user)
# now the namespace chosen by user is loaded.
Best regards
[ ]s
Does this do what you want?
(defn require-from-string [s]
(require (symbol s)))
Andy
On Jun 8, 2012, at 5:37 PM, Leandro Oliveira wrote:
Hi,
What is the best way to implement require-from-string?
Ex:
# require-from-string words like require but accepts namespaces as strings.
On Thu, Jun 7, 2012 at 8:32 PM, David Jacobs da...@wit.io wrote:
I would love to have a version of doseq that works like map (similar to
each in other dynamic languages). In other words, instead of (doseq [log
logs] (println log)), I would say something like (each println logs).
Since that
On Fri, Jun 8, 2012 at 4:35 AM, Gabo delmasc...@gmail.com wrote:
I'm actually working on a simple function which would replace the nth
element of a vector.
(assoc v n e) ;; returns a new vector with the nth element of v replaced by e
Note that it does not change the original vector.
(def
The clojure.pamphlet file is latex source code which is plain text.
Tim Daly
--
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
Note that posts from new members are moderated - please be
59 matches
Mail list logo