On Tuesday, 23 April 2013 13:37:59 UTC-7, Steven Degutis wrote:
While this is certainly neat, it doesn't allow Clojure to be used as
an embedded scripting language inside an ObjC app.
Since the Clojure/West talk I've been busy trying to get clojure-scheme
self-hosted. I've been a week or
ClojureScript doesn't complain when you supply too many arguments to a
function, silently dropping the superfluous args. Is this a bug or feature?
I'm not sure if I should replicate this behaviour in clojure-scheme, as it
differs from Clojure.
P.S. is there a separate group for ClojureScript
ClojureScript has plenty of sharp edges, and this project is a bit rougher
than even ClojureScript at the moment so you'll have to pardon the mess.
The magic happens in the cljs.compiler namespace. Load up a clojure repl
and do something along the lines of:
(do (require 'cljs.compiler)
When trawling the ClojureScript source, I was a little puzzled when I first
noticed that cljs.core/apply respects the laziness of the seq its provided.
Fogus mentioned this feature in his Clojure/west talk and it reminded me of
my earlier puzzlement.
This choice seems to contradict Clojure's
Your right the core apply is lazy too. The same question still remains: is
there a use case behind apply being lazy when Clojure is otherwise a
strictly evaluating language? Perhaps is this the intended mechanism to
smuggle non-strictness into evaluation?
--
You received this message because
Actually now that I've thought about it, you couldn't mimic non-strict
evaluation with lazy apply, so that's not a use-case. All you could provide
is left-to-right argument non-strictness which is not sufficient. W.r.t.
your example, you can force evaluation the first 3 args, but you can't,
I don't think it's possible to ever have apply not evaluate all its
arguments? I think this is what Nathan was saying.
Cedric is right that apply, itself, is strict and evaluates its arguments
as one might expect. But I'm not referring to manual thunking/delaying your
arguments to mimic
An example of lazy apply, with your foo fn:
(apply foo (iterate inc 0))
d
--
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 patient
One example, in the frontend we wrap all the database calls in a caching
layer but we don't need that when the same code runs in the backend.
One option for something like this (a configuration option that doesn't
change much between function calls/expected to largely remain the same for
Put another way: why does apply need to promise not to realize its seq
argument?
(apply + some-lazy-seq-too-big-to-fit-in-main-memory)
Not avoid evaluating some of its arguments but avoid holding onto
the head in that case.
I'd reach for 'reduce' in this case but that's still a valid
I see the C code generation as an advantage, in that it becomes possible to
target any platform with a C compiler.
Can Clozure compile to iOS?
Just a question, why Clojure-Scheme-C, instead of Clojure-Clozure?
That way there would no be any C compiler dependency.
--
You received this
I've modified the output of the ClojureScript compiler to emit Scheme code.
At this point the core library is successfully compiled by Gambit Scheme. A
nice advantage of this is that Gambit compiles code via C, meaning that
stand-alone Clojure executables are now available for any platform with
Couple of things to watch out for, Clojure doesn't pattern match on the
args in the way you seem to be expecting, so this will blow the stack (i.e.
calling qsort with the empty list won't call the 0-argument method you have
there.)
The error you're running into is that pop/peek isn't defined
Obviously the example of doall not being up to the task should read:
scratch (type (doall (lazy-seq [1 2 3])))
clojure.lang.LazySeq
--
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
If you were feeling so inclined, you could structure this as a lazy sequence
(like 'partition' does)
(defn lazy-break
[coll]
(letfn [(break-paired [pairs]
(lazy-seq
(when-let [s (seq pairs)]
(let [p (doall (take-while (fn [[a b]] (= (inc a) b)) pairs))
I'm using clojure.walk/postwalk to rewrite terms in nested data
structures. However, I am unable to do this with types as defined by
defrecord, because they specify that the function empty throw a not-
implemented exception.
If I were able to over-ride this default implementation of 'empty' I
for the work!
cheers
Paul
On Fri, Sep 23, 2011 at 04:47, Nathan Sorenson n...@sfu.ca wrote:
Yes I am very hopeful progress is made on that front! I've been having
great success with 'Constraint Handling Rules' (CHR), which serves as
my basis for solving type constraints.
https
You're right that my use isn't strictly returning a collection with a size
of zero-- I'm treating empty more like 'default'. I'm thinking of its use in
clojure.walk, which simply creates a blank version of an arbitrary
collection in which to place the altered sub-forms. I can't find any other
Because the fn is wrapped in a lazy sequence, the effects won't run if you
ask for the same value again--
For instance:
(def a (iterate (fn [cnt]
(prn cnt)
;; save data to csv
(inc cnt)) 0))
(nth a 5) ... all the effects are fired.
(nth a 5) ...
Quite often I convince myself I need state or some effectful trigger, but
further thought reveals a simpler stateless approach.
That being said--if you absolutely need to be doing something based on
effects, something that absolutely can't be tracked via values in a purely
functional way--like
You're right on the doorstep again :)
If you want to make a single, flat list out of two different lists,
the function you're looking for is 'concat'
You may find the cheat sheet helpful: http://clojure.org/cheatsheet.
In this case you were looking for some operation on sequences which
gave you
Yes I am very hopeful progress is made on that front! I've been having
great success with 'Constraint Handling Rules' (CHR), which serves as
my basis for solving type constraints. https://github.com/nsorenson/Clojure-CHR
contains my very preliminary crack at implementing this system.
The trick
What are your ideas? You can implement a balanced k-d tree on top a normal
vector, so that would be my first thought.
--
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
Just to clarify, you want to conj a vector to itself? i.e. [1 2 3 4] -- [1
2 3 4 [1 2 3 4]] I'm curious what the application of this is.
Regarding the overhead of conj-ing to a vector: Clojure's data structures
make use of structural sharing so conjoining an element to the end of a
vector
A recursive formulation is exactly the right idea. Also, you're right
when you say it won't work with recur as you've set it up. In fact,
you won't be able to use recur at all in this situation as a you are
doing a depth-first search through possible paths--it's impossible to
formulate a
These types of discussions seem to get very broad in their scope and
not much is ever settled.
That being said, it seems one place where dynamic typing is a huge
advantage is for records--Clojure records are prevalent and extremely
easy to use, and are an excellent substrate for where we would
long entails a call to RT/longCast, which dynamically dispatches on
the type of the object passed to it. I haven't tested this, but i
would imagine the java cast would compile directly to the single byte-
code instruction i2l. Presumably, then, the java call would be a touch
faster by a few
Futures begin executing their contents immediately, you don't have to
deref them to trigger the side effects. (perhaps you were thinking of
delay?)
I'm assuming you are using futures because email-request is an io-
blocking operation? The thing to note is that the body of a future
automatically
I adore Clojure as well, but could this success not be partially due
to the reimplementing for the second time phenomenon? i.e. if you re-
wrote the entire thing in Scala again, perhaps you would see similar
gains in brevity etc?
On Sep 6, 10:32 pm, Sean Corfield seancorfi...@gmail.com wrote:
I
Batik can serialize to both PNG and PDF. http://xmlgraphics.apache.org/batik/
I currently use Batik in a clojure project doing a lot of drawing of
2d vector-based images. It's a very extensive library but it suits my
needs well.
On Apr 29, 9:26 pm, stu stuart.hungerf...@gmail.com wrote:
Hi,
, 10:54 am, Nathan Sorenson n...@sfu.ca wrote:
(transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
exception. Is this expected/unavoidable? How do I know whether the
vectors I'm passed are regular vectors or come via subvec?
I'm assuming I lose all the performance benefits
kwess...@gmail.com wrote:
On Sat, Apr 30, 2011 at 11:27 AM, Armando Blancas
armando_blan...@yahoo.com wrote:
On Apr 29, 10:54 am, Nathan Sorenson n...@sfu.ca wrote:
(transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
exception. Is this expected/unavoidable? How do I know whether
(transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
exception. Is this expected/unavoidable? How do I know whether the
vectors I'm passed are regular vectors or come via subvec?
I'm assuming I lose all the performance benefits of subvec if I
defensively pour all vectors into a new vector
I want to examine the namespace within a swing thread, as I want to
see if a particular var is defined from another part of the program
before operating on it. However, inside the do-swing macro (or just
using SwingUtilities/invokeLater directly) *ns* will always refer to
clojure.core, not the
In my clojure repl, i'm now seeing CTRL-M characters at the end of
each line printed to the repl (println commands, doc commands etc...).
If I launch the swank-repl from Cygwin I still see these ^M's. Am I to
assume this relates to this added feature: Java's line.separator
property for newline?
I'm using Windows 7, and again, I see this behaviour when using the
regular windows shell or Cygwin to launch the swank-repl.
On Mar 16, 12:10 pm, Nathan Sorenson n...@sfu.ca wrote:
In my clojure repl, i'm now seeing CTRL-M characters at the end of
each line printed to the repl (println
I've always wanted to have an in-game scripting console that has
access to some of the functionality I'm used to in emacs, like
paredit. This would actually be really useful in achieving this, I
think!
On Jan 19, 1:44 am, Laurent PETIT laurent.pe...@gmail.com wrote:
Hello,
2011/1/18 Olek
After reading Oleg's lecture Typed tagless-final interpretations
( http://okmij.org/ftp/tagless-final/course/ ), I decided to see if
this was possible, or made any sense, to follow this style in
Clojure.
The idea is that, instead of representing a DSL syntax as a data
structure that you
I was discussing this on the clojure channel, and it seems as though
avoiding explicit recursion is the idiomatic thing to do. Is there a
better way to define a function that loops over an arbitrary number of
sequences in a nested fashion, similar to the 'for' macro, without
relying on recursion?
That's perfect, thanks!
On Sep 30, 4:55 pm, Mark Engelberg mark.engelb...@gmail.com wrote:
clojure.contrib.cartesian-product does what your nested function does,
but more efficiently, using iteration rather than recursion.
--
You received this message because you are subscribed to the Google
is not a macro but a closure:
(defn hidden-atom []
(let [a (atom :hello)]
(fn [] (deref a
(def x (hidden-atom))
(x)
;;= :hello
-S
On Sep 19, 12:32 am, Nathan Sorenson n...@sfu.ca wrote:
I am playing around with a macro to define accessor functions
I am playing around with a macro to define accessor functions for a
closed-over atom. Here is a simplified example:
(defmacro hidden-atom []
(let [a (atom :hello)]
`(defn get-value [] (deref ~a
When I evaluate this macro, I get the error: Can't embed object in
code, maybe print-dup not
to know the destructuring approach is more or less
the obvious way to go about things, and I am not overlooking an
idiomatic approach.
On Jun 12, 3:53 am, Jürgen Hötzel juer...@hoetzel.info wrote:
2010/6/11 Nathan Sorenson n...@sfu.ca:
Is there a way to fold over multiple sequences, in the same way
Is there a way to fold over multiple sequences, in the same way that
'map' can apply a multi-parameter function over several seqs? In other
words, is there a function like this:
(defn reduce*
[f val colls]
(reduce (fn [acc args] (apply f acc args))
val
First of all, I would like to thank Rich and this community for
producing such a pleasurable language, and for putting up with with
all the unpleasant nit-picking of new users. That being said...
I am curious as to why the function parameter is specified before the
collection parameter in
The let- macro looks very useful. Thank-you!
--~--~-~--~~~---~--~~
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, send email to
46 matches
Mail list logo