Re: Clojure on top of ObjC?

2013-05-05 Thread Nathan Sorenson
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 allows fns to be called with too many arguments

2012-04-04 Thread Nathan Sorenson
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

Re: clojure-scheme - Compiling Clojure to Scheme to C

2012-03-28 Thread Nathan Sorenson
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)

motivation behind laziness of apply in ClojureScript

2012-03-28 Thread Nathan Sorenson
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

Re: motivation behind laziness of apply in ClojureScript

2012-03-28 Thread Nathan Sorenson
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

Re: motivation behind laziness of apply in ClojureScript

2012-03-28 Thread Nathan Sorenson
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,

Re: motivation behind laziness of apply in ClojureScript

2012-03-28 Thread Nathan Sorenson
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

Re: motivation behind laziness of apply in ClojureScript

2012-03-28 Thread Nathan Sorenson
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

Re: Polymorphic namespaces?

2012-03-28 Thread Nathan Sorenson
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

Re: motivation behind laziness of apply in ClojureScript

2012-03-28 Thread Nathan Sorenson
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

Re: clojure-scheme - Compiling Clojure to Scheme to C

2012-03-21 Thread Nathan Sorenson
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

[ANN] clojure-scheme - Compiling Clojure to Scheme to C

2012-03-14 Thread Nathan Sorenson
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

Re: Quicksort

2012-02-10 Thread Nathan Sorenson
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

Re: Quicksort

2012-02-10 Thread Nathan Sorenson
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

Re: break-on-gaps - just curious if there is a more idiomatic way to do this

2011-09-28 Thread Nathan Sorenson
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))

defrecord and overriding empty

2011-09-27 Thread Nathan Sorenson
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

Re: advantage of dynamic typing

2011-09-27 Thread Nathan Sorenson
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

Re: defrecord and overriding empty

2011-09-27 Thread Nathan Sorenson
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

Re: iterate with side-effect function?

2011-09-27 Thread Nathan Sorenson
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) ...

Re: iterate with side-effect function?

2011-09-27 Thread Nathan Sorenson
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

Re: Recursion/Algorithm Question

2011-09-22 Thread Nathan Sorenson
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

Re: advantage of dynamic typing

2011-09-22 Thread Nathan Sorenson
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

Re: using finger trees in two dimensions

2011-09-22 Thread Nathan Sorenson
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

Re: Addition of new a priori distinct element to a vector

2011-09-22 Thread Nathan Sorenson
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

Re: Recursion/Algorithm Question

2011-09-21 Thread Nathan Sorenson
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

Re: advantage of dynamic typing

2011-09-21 Thread Nathan Sorenson
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

Re: clojure type casting vs java type casting

2011-09-21 Thread Nathan Sorenson
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

Re: Spread work onto multiple threads (in pure Clojure)

2011-09-21 Thread Nathan Sorenson
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

Re: Clojure vs Scala - anecdote

2011-09-13 Thread Nathan Sorenson
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

Re: 2D graphics options with Clojure?

2011-04-30 Thread Nathan Sorenson
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,

Re: SubVector's (via 'subvec') do not support 'transient'

2011-04-30 Thread Nathan Sorenson
, 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

Re: SubVector's (via 'subvec') do not support 'transient'

2011-04-30 Thread Nathan Sorenson
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

SubVector's (via 'subvec') do not support 'transient'

2011-04-29 Thread Nathan Sorenson
(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

*ns* unexpectedly changing on me, via SwingUtilities/invokeLater

2011-03-18 Thread Nathan Sorenson
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

Emacs slime repl now printing carriage returns after Clojure 1.3.0-alpha5

2011-03-16 Thread Nathan Sorenson
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?

Re: Emacs slime repl now printing carriage returns after Clojure 1.3.0-alpha5

2011-03-16 Thread Nathan Sorenson
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

Re: ANN: Textmash - another IDE for Clojure

2011-01-19 Thread Nathan Sorenson
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

Tagless-final Interpretations in Clojure (can it be done better than this?)

2011-01-16 Thread Nathan Sorenson
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

Any clean way to avoid explicit recursion when creating nested loops?

2010-09-30 Thread Nathan Sorenson
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?

Re: Any clean way to avoid explicit recursion when creating nested loops?

2010-09-30 Thread Nathan Sorenson
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

Re: Macro closing over atom gives Can't embed object in code error.

2010-09-19 Thread Nathan Sorenson
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

Macro closing over atom gives Can't embed object in code error.

2010-09-18 Thread Nathan Sorenson
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

Re: Reduce a function over more than one sequence (like map)

2010-06-12 Thread Nathan Sorenson
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

Reduce a function over more than one sequence (like map)

2010-06-11 Thread Nathan Sorenson
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

Parameter ordering on map/reduce

2009-03-31 Thread Nathan Sorenson
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

Re: Parameter ordering on map/reduce

2009-03-31 Thread Nathan Sorenson
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