Re: require :require

2013-12-06 Thread Jonathan Fischer Friberg
Inside the ns form they are the same. Outside the ns form, only (require '[a.b]) works (with quoting, as Kelker said). Jonathan On Fri, Dec 6, 2013 at 10:24 AM, Kelker Ryan theinter...@yandex.com wrote: I believe one is a directive and the other is a function. :require doesn't need the

Re: Like if, but it composes functions

2013-02-20 Thread Jonathan Fischer Friberg
Function composition similar to that has been explored a lot in the haskell world. See: http://www.haskell.org/haskellwiki/Arrow I also made a small library to implement some of the operators: https://github.com/odyssomay/clj-arrow I think the reason arrows are so interesting in haskell is

Re: features expression

2013-03-07 Thread Jonathan Fischer Friberg
Isn't it possible to solve this with a simple macro? (case-dialect :clojure (... clojure code ...) :clojurescript (... clojurescript code ...)) Then, in jvm clojure, it could be implemented as: (defmacro case-dialect [ {:keys [clojure]}] clojure) and in clojurescript: (defmacro

Re: features expression

2013-03-07 Thread Jonathan Fischer Friberg
of things you would want to conditionally compile on for Clojure/JVM. Andy On Thu, Mar 7, 2013 at 5:44 AM, Jonathan Fischer Friberg odysso...@gmail.com wrote: Isn't it possible to solve this with a simple macro? (case-dialect :clojure (... clojure code ...) :clojurescript

Re: Windows Installation

2013-03-09 Thread Jonathan Fischer Friberg
My experience: 1. Download lein.bat 2. Run it Jonathan On Sat, Mar 9, 2013 at 10:23 AM, BJG145 benmagicf...@gmail.com wrote: Perhaps this general anti-Windows attitude is what Windows-based newcomers to Clojure find off-putting... On Saturday, March 9, 2013 3:55:59 AM UTC, James Ashley

Re: :use an entire namespace full of protocols or stick with :require?

2013-03-10 Thread Jonathan Fischer Friberg
I would say using :require :as is in almost all cases better. However, I think :use is preferred if almost everything done in the current namespace depends on the used namespace. Though, no more than one namespace should ever be imported with :use in the same namespace. In your case I think it's

Re: What's the point of - ?

2013-03-11 Thread Jonathan Fischer Friberg
- and - are for some reason really hard to grasp for many when starting out - me included. On Mon, Mar 11, 2013 at 11:58 AM, edw...@kenworthy.info wrote: So I understand that: (- foo bar wibble) is equivalent to (wibble (bar (foo))) Correct, but that misses the point. Thinking about -

Re: ANN Validateur 1.4 is released

2013-03-12 Thread Jonathan Fischer Friberg
We recommend all users to upgrade to 1.7.0https://clojars.org/com.novemberain/validateur/versions/1.7.0 . I'm guessing it should be 1.4.0? Jonathan On Tue, Mar 12, 2013 at 8:58 PM, Michael Klishin michael.s.klis...@gmail.com wrote: Validateur is a functional validations library inspired by

Re: Java interop with dynamic proxies

2013-03-12 Thread Jonathan Fischer Friberg
I think you can simply use 'Fred' instead of 'Fred.class'. Since, in the repl: (class Integer) ;= java.lang.Class I.e. just by using the name, we get a Class object, which should correspond to .class in java. In other words, you should be able to run: (let [f (Factory/createInstance)

Re: doing a Google search from Clojure?

2013-03-22 Thread Jonathan Fischer Friberg
Found some info here: http://stackoverflow.com/questions/3727662/how-can-you-search-google-programmatically-java-api Jonathan On Fri, Mar 22, 2013 at 8:32 AM, Cedric Greevey cgree...@gmail.com wrote: Change your code to it spoofs a common browser user-agent, change your DHCP-assigned IP

Re: a bug?

2013-03-27 Thread Jonathan Fischer Friberg
The problem is probably too much nested laziness. Try: (reduce (fn [a b] (doall (map + [1 1] a))) [1 1] (range 1500)) Related: https://groups.google.com/d/msg/clojure/-d8m7ooa4c8/pmaO7QubhosJ Jonathan On Wed, Mar 27, 2013 at 8:48 PM, Michael Klishin michael.s.klis...@gmail.com wrote:

Re: a bug?

2013-03-27 Thread Jonathan Fischer Friberg
I don't think it's fixed in 1.5.1. In both 1.5.0 and 1.5.1, (range 1500) is not enough to cause the overflow for me. However, (range 2000) successfully overflows in both versions. Jonathan On Wed, Mar 27, 2013 at 8:53 PM, Timothy Baldridge tbaldri...@gmail.comwrote: Holding on to the head

Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
It's because the #() syntax always calls the content as a function. So #(...) is the same as (fn [] (...)). In your case, #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) is the same as: (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})) Note the extra () around {}. In other words,

Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
columns which they use underscore so I gotta go with underscores in order code to match them :) Ryan On Thursday, March 28, 2013 11:24:38 PM UTC+2, Jonathan Fischer Friberg wrote: It's because the #() syntax always calls the content as a function. So #(...) is the same as (fn

Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
that #() executes the content as a function, very helpful! Ryan On Friday, March 29, 2013 12:08:04 AM UTC+2, Jonathan Fischer Friberg wrote: It can still be done with the #(), with for example the hash-map function. It's basically the same as the {} but as a function, like this: (hash-map :a 3 :b 4

Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Jonathan Fischer Friberg
I think group-by can do what you want (and more); http://clojuredocs.org/clojure_core/clojure.core/group-by Jonathan On Thu, Apr 4, 2013 at 2:16 PM, Christian Romney xmlb...@gmail.com wrote: Hi all, I was wondering if something in core (or new contrib) like this exists already... (defn

Re: Memoization in clojure

2013-04-14 Thread Jonathan Fischer Friberg
(letfn [(fib [x] (memoize #(if (or (zero? %) (= % 1)) 1 (+ (fib (- % 1)) (fib (- % 2))] (time (fib 30)) (time (fib 30)) (time (fib 40)) (time (fib 40))) Calling fib just creates a new function, no values are calculated. So

Re: Memoization in clojure

2013-04-14 Thread Jonathan Fischer Friberg
Oops ;) Of course you are right. The amazing thing is that the times I observed fitted somehow the situation (the first (fib 30) call taking much more time than the others, the third call more than the second and fourth) that I was tricked into believing the calculations were being done and

Re: Do functions never get inlined by jvm?

2013-04-25 Thread Jonathan Fischer Friberg
If that's a problem, you could try https://github.com/hugoduncan/criterium On Thu, Apr 25, 2013 at 5:38 PM, Phil Hagelberg p...@hagelb.org wrote: Three repetitions is not nearly enough to get a feel for how hotspot optimizes functions when it detects they're in a tight loop. I don't know how

Re: cannot read foo.xml from the top level of a jar!

2013-04-26 Thread Jonathan Fischer Friberg
Did you put / at the beginning of the string to resource? Because you shouldn't. You should call it like this: (resource foo.xml). Jonathan On Fri, Apr 26, 2013 at 8:47 PM, Jim - FooBar(); jimpil1...@gmail.comwrote: Hello everyone, I hope you're all doing well... Can anyone enlighten my

Re: Now *there*'s a machine made for Clojure.

2013-04-29 Thread Jonathan Fischer Friberg
You could always give https://github.com/halgari/clojure-py a spin, might not be so easy to get everything working though. :) Jonathan On Mon, Apr 29, 2013 at 2:48 PM, Lee Spector lspec...@hampshire.edu wrote: On Apr 29, 2013, at 8:15 AM, Michiel Overtoom wrote: On Apr 28, 2013, at

Re: testing for nil may not be enough

2013-04-29 Thread Jonathan Fischer Friberg
If you don't want to set the initial value to nil, set it to ::unbound or similar. Should be very hard to accidentally bind the same value. Jonathan On Mon, Apr 29, 2013 at 8:04 PM, AtKaaZ atk...@gmail.com wrote: the pain with that is that it wouldn't work inside a function where a would be

Re: Using a Java game engine in my project

2013-04-29 Thread Jonathan Fischer Friberg
I'm currently making a library for jmonkeyengine. It's not ready yet, however, a while back I decided to put jme in a repository. Url: http://jmonkeyengine.s3-website-eu-west-1.amazonaws.com/; Add to deps: [jme 2013-04-01] The biggest problem with it right now is that it contains all test models

Re: Now *there*'s a machine made for Clojure.

2013-04-29 Thread Jonathan Fischer Friberg
On Mon, Apr 29, 2013 at 5:25 PM, Konrad Hinsen googlegro...@khinsen.fastmail.net wrote: --On 29 avril 2013 09:09:27 -0400 Lee Spector lspec...@hampshire.edu wrote: On Apr 29, 2013, at 9:01 AM, Jonathan Fischer Friberg wrote: You could always give https://github.com/halgari/**clojure

Re: Now *there*'s a machine made for Clojure.

2013-04-29 Thread Jonathan Fischer Friberg
don't support better. Everything from concurrency to the GC is implemented better in the JVM. Timothy On Mon, Apr 29, 2013 at 2:41 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: On Mon, Apr 29, 2013 at 5:25 PM, Konrad Hinsen googlegro...@khinsen.fastmail.net wrote: --On 29

Re: Using a Java game engine in my project

2013-04-30 Thread Jonathan Fischer Friberg
I think that for today I will stick with the lib folder solution, proposed by James, but I encourage the knowledgefull people Jonathan and James to work together to deliver a Clojars or Amazonaws online repository with more-or-less daily update, since the engine is really well-maintained.

Re: A JMonkeyEngine3 wrapper?

2013-05-01 Thread Jonathan Fischer Friberg
My effort can be found here: https://github.com/odyssomay/orbit It's kind of all over the place in that I have started on a lot of things, but not really finished any parts. In any case, should be some useful stuff in there. I haven't really been active on the project lately - there's a bunch of

Re: A JMonkeyEngine3 wrapper?

2013-05-01 Thread Jonathan Fischer Friberg
. Jonathan On Wed, May 1, 2013 at 11:20 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: My effort can be found here: https://github.com/odyssomay/orbit It's kind of all over the place in that I have started on a lot of things, but not really finished any parts. In any case, should

Re: A JMonkeyEngine3 wrapper?

2013-05-01 Thread Jonathan Fischer Friberg
UI example: https://github.com/odyssomay/orbit/blob/master/test/orbit/test/ui.clj#L45 Sorry for the spam. :) Jonathan On Wed, May 1, 2013 at 11:28 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: Some info about the current status: * Input handling - missing joystick

Re: idiomatic way to force evaluation of a lazy operation

2013-05-04 Thread Jonathan Fischer Friberg
If you don't need the result, you should use dorun instead of doall. http://clojuredocs.org/clojure_core/clojure.core/dorun Jonathan On Sat, May 4, 2013 at 8:07 PM, Gary Verhaegen gary.verhae...@gmail.comwrote: Just want to point out that doall seeming more idiomatic in this case might just

Re: [ANN] bleach 0.0.11

2013-05-04 Thread Jonathan Fischer Friberg
You could try reading about it here: http://search.cpan.org/~dconway/Acme-Bleach-1.150/lib/Acme/Bleach.pm I still can't figure out exactly what it does though... Reading the description, it seems like it removes, for example whitespace at the end of lines. But from the example it seems like it

Re: Using a Java game engine in my project

2013-05-05 Thread Jonathan Fischer Friberg
That sounds scary. :) I haven't experienced any of the sort. Tested in both linux 64-bit and windoze 32-bit. The problem likely stems from the way jme loads the native libraries. As far as I know they do it manually by extracting the libraries and then setting some sort of path. It should be

Re: Import java classes in clojure

2013-05-05 Thread Jonathan Fischer Friberg
(:import ...) only works in (ns ...). Outside ns, you have to use (import ...) instead (note: no :). See: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html Jonathan On Mon, May 6, 2013 at 12:04 AM, Caocoa p.de.bois...@gmail.com wrote:

Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
I haven't used clojurescript in a while, but if I recall correctly, the only way to not compile everything into a single file is to leave out the :optimization flag completely. If this is the case this should probably be considered a bug. I might be wrong though. Jonathan On Tue, May 7, 2013 at

Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
groups of them with different lein-cljsbuild groups. On Tue, May 7, 2013 at 12:24 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: I haven't used clojurescript in a while, but if I recall correctly, the only way to not compile everything into a single file is to leave out

Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
abouve. Maybe I just can't do this, but I thought I'd ask around. Tim On Tue, May 7, 2013 at 4:03 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: From the sample.project.clj: ; Determines whether the temporary JavaScript files will be left in place between ; automatic builds

Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
*DON'T DO IT* I just realised, if the :optimizations missing triggers this behaviour, it should be possible to set it to nil, and it was! So try ':optimizations nil' in your build. Jonathan On Tue, May 7, 2013 at 10:20 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: I tried

Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
, ['edgar'], ['cljs.core', 'clojure.browser.repl', 'shoreleave.remotes.http_rpc']); *main.js * Hmm Tim On Tue, May 7, 2013 at 4:37 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: *DON'T DO IT* I just realised, if the :optimizations missing triggers this behaviour, it should

Re: Separating Out .cljs Content

2013-05-08 Thread Jonathan Fischer Friberg
:8080/javascript/edgar.js Tim On Tue, May 7, 2013 at 5:26 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: You have to import the google closure library when compiling without optimisation. Given your build, probably something like this: script type=text/javascript src=public

Re: Struggling with encapsulation

2013-05-09 Thread Jonathan Fischer Friberg
I agree with Gary, there's normally not really any need to obfuscate the implementation, and using the underlying structure can sometimes be useful. That said, if you really want to, you can create a woobly protocol and implement it using reify, this will make the underlying implementation

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-11 Thread Jonathan Fischer Friberg
On Sat, May 11, 2013 at 9:25 PM, Alex Baranosky alexander.barano...@gmail.com wrote: Most of the code I see and write at work at Runa uses (not (empty? foo)). I'll continue to defend the position that it is more obvious code, and therefore better (imo :) ) Alex Completely agree. (seq

Re: Screencast: Clojure development with Sublime Text 2

2013-05-18 Thread Jonathan Fischer Friberg
Nice introduction! Problems/suggestions for lispindent can be reported here: https://github.com/odyssomay/sublime-lispindent/issues don't be shy! In any case, I went ahead and implemented checking for the syntax of the file. So non-saved files with clojure syntax is now indented correctly. This

Re: find first match in a sequence

2013-05-19 Thread Jonathan Fischer Friberg
On Sun, May 19, 2013 at 4:54 PM, Jim - FooBar(); jimpil1...@gmail.comwrote: ha! you cheated with iterate... try this which is closer to the example... (first (filter odd? (map #(do (println realized %) %) [2 4 6 7 8 9]))) realized 2 realized 4 realized 6 realized 7 realized 8

Re: user math expression evaluation

2013-05-28 Thread Jonathan Fischer Friberg
Found this: http://www.objecthunter.net/exp4j/ Might be useful. Jonathan On Wed, May 29, 2013 at 12:45 AM, SpiderPig spiderpi...@googlemail.comwrote: You could just write this yourself. It's easier than it looks. First start with an evaluator for rpn (reverse polish notation) expressions.

Re: using partial with -

2013-06-07 Thread Jonathan Fischer Friberg
On Fri, Jun 7, 2013 at 11:13 PM, Matt Smith matt.smith...@gmail.com wrote: (- '([1 2] [3 4] [5]) (partial map first) flatten ) Because this becomes (flatten (partial '([1 2] [3 4] [5]) map first)) I think I understand how you thought; (partial map first) becomes a function,

Re: Re: eval and load-string behavior

2011-06-22 Thread Jonathan Fischer Friberg
Yes, unless you wrap it in another macro. (defmacro a [] (vec (map (fn [x] `(load-string-here ~x)) [1 2 3 4]))) = (a) [1 2 3 4] But it's still pretty useless, unless macros are to replace functions... Jonathan On Wed, Jun 22, 2011 at 8:20 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi,

Re: ANN: Hafni

2011-06-24 Thread Jonathan Fischer Friberg
stumbled upon another, abandoned Clojure+Swing project called ... wait for it... Seesaw. Go figure :) Best regards, Dave On Mon, Jun 20, 2011 at 7:57 AM, Jonathan Fischer Friberg odysso...@gmail.com wrote: Hi, I figured that I would announce a library that I have been working

Re: ANN: Hafni

2011-07-06 Thread Jonathan Fischer Friberg
inc) (arr inc)) 1) ;; 4 ((*** (arr inc) (arr dec)) [1 1]) ;; [2 0] (( (arr inc) (arr dec)) 1) ;; [2 0] ((fst (arr inc)) [1 1]) ;; [2 1] Scott On Mon, Jun 20, 2011 at 7:57 AM, Jonathan Fischer Friberg odysso...@gmail.com wrote: Hi, I figured that I would announce

Re: Please stand firm against Steve Yegge's yes language push

2011-07-07 Thread Jonathan Fischer Friberg
On Thu, Jul 7, 2011 at 7:42 AM, nchubrich nchubr...@gmail.com wrote: * Since Lisp is highly extensible, in the long run being 'prescriptive' is a losing battle. It is better to eventually add standard 'bad' features to the language than to tempt third parties to do it in even worse and

Re: Please stand firm against Steve Yegge's yes language push

2011-07-08 Thread Jonathan Fischer Friberg
On Fri, Jul 8, 2011 at 4:29 PM, James Keats james.w.ke...@gmail.com wrote: May I also add the following caveat emptors: - If you're new to programming, clojure will overwhelm you. Start with something like python. I think most programming languages overwhelm you if you don't have any prior

Re: Vagrant setup [was Re: Please stand firm against Steve Yegge's yes language push]

2011-07-08 Thread Jonathan Fischer Friberg
It looks like you haven't got enough privileges, try sudo gem install vagrant Jonathan On Fri, Jul 8, 2011 at 6:58 PM, Lee Spector lspec...@hampshire.edu wrote: On Jul 8, 2011, at 12:38 PM, Vivek Khurana wrote: That is still not as easy as python. Running VM is a bigger overhead... There

Re: Please stand firm against Steve Yegge's yes language push

2011-07-08 Thread Jonathan Fischer Friberg
I don't agree that clojure is, or should be seen as something entirely different than java. If it weren't for java, clojure wouldn't have much use at all. When it comes to IDEs, I agree. I write all code in vim (for editing only), and do the rest from the command line (meaning mostly leiningen).

Re: Recommendation for Clojure Enterprise Development toolkit

2011-07-09 Thread Jonathan Fischer Friberg
That's not very constructive at all. I think clojure would work fine (or better) for enterprise applications. The one thing that could pull it down is maintainability, as the maintainers must know clojure. There was recently a thread about working on large programs in clojure. It might contain

Re: Looking for examples of using Java iterators from Clojure...

2011-07-09 Thread Jonathan Fischer Friberg
Maybe this would do: https://gist.github.com/1073506 I should add that I have never used iterators, and that the code is untested ;) Jonathan On Sat, Jul 9, 2011 at 11:10 AM, stu stuart.hungerf...@gmail.com wrote: Hi, I'd like to make use of Java classes implementing the Java2D

Re: Looking for examples of using Java iterators from Clojure...

2011-07-09 Thread Jonathan Fischer Friberg
I don't think I like the notion of a lazy-seq and an iterator, since reading the iterator also changes it. Consider the case where you create a lazy-seq from an iterator, and the iterator somehow escapes. Somewhere else the iterator is read from, and now the data that where supposed to be in the

Re: Looking for examples of using Java iterators from Clojure...

2011-07-09 Thread Jonathan Fischer Friberg
Well, I guess. But I get the feeling that the iterator are probably coming from some java object somewhere, and might get passed around in that environment, that's why I'm worried. In the examples you mentioned, line-seq for example. The reader has already 'escaped' since it is passed as an

Re: Extending a type to an Interface

2011-07-10 Thread Jonathan Fischer Friberg
I think the reason is that an interface means that the function must be 'inside' the class. I.e you can call (.method object). Since it isn't possible to extend a java class in that way, it isn't possible to use extend. In a defrecord body however, a new class is defined, which means that it's

Re: Local bindings w/o let

2011-07-10 Thread Jonathan Fischer Friberg
There's no interfaces, that's the function definition. define function max (defn max attach docstring Returns the greatest of the nums. attach metadata {:added 1.0} if max is called with one argument, use this function definition ([x] x) if max is called with two arguments, use this function

Re: Results from 2011 State of Clojure survey

2011-07-13 Thread Jonathan Fischer Friberg
All those are available in 1.2, or am I missing something? From my own experience: metadata, when I started to learn clojure, I thought this is awesome. When I realized that metadata only applies to clojure types, it felt unreliable and I never got to using it. protocols records/types - they're

Re: Noobie needs help

2011-07-14 Thread Jonathan Fischer Friberg
def defines a global binding (i.e. you can reach the symbol from everywhere). defn does the same thing, but always binds the symbol to a function. Therefore, you only need either def OR defn. (defn string-maker [the-string] (str the-string)) OR (def string-maker (fn [the-string] (str

Re: Noobie needs help

2011-07-14 Thread Jonathan Fischer Friberg
I see I misunderstood the question, sorry about that. What you want is a macro: (defmacro string-maker [string-name the-string] `(def ~(symbol string-name) ~the-string)) Jonathan On Thu, Jul 14, 2011 at 1:13 PM, Giancarlo Angulo igan.l...@gmail.comwrote: Please look at this:

Re: Modelling relationships between objects

2011-08-04 Thread Jonathan Fischer Friberg
I like to have the datastructure as one big mutable structure. It's not optimal in many cases, but it is simple. In this case you could have something like: (def NoteDb (atom [{:text a note :category :misc} {:text note 2 :category :misc} {:text blabla :category :important}])) (defn

Re: [ANN] CongoMongo 0.1.6

2011-08-05 Thread Jonathan Fischer Friberg
Might be appropriate: https://github.com/aboekhoff/congomongo Jonathan On Fri, Aug 5, 2011 at 1:29 AM, Sean Corfield seancorfi...@gmail.comwrote: Available on Clojars. Compatible with Clojure 1.2 and Clojure 1.3. Fixes (almost) all reflection warnings. Handles multi-server connections (bug

Re: What's wrong with my *print-dup* persistence?

2011-09-11 Thread Jonathan Fischer Friberg
Or (load-string (+ 1 (+ 2 4))) Jonathan On Fri, Sep 9, 2011 at 5:14 PM, Chouser chou...@gmail.com wrote: On Thu, Sep 8, 2011 at 5:16 PM, Tassilo Horn tass...@member.fsf.org wrote: Hi all, I've just read Alan Malloy's excellent clojure persistence article at

Re: debugging

2011-09-11 Thread Jonathan Fischer Friberg
Sort of. http://georgejahad.com/clojure/cdt.html Jonathan On Sat, Sep 10, 2011 at 5:36 PM, Dennis Haupt d.haup...@googlemail.comwrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hi there, what's the currently best way to debug a clojure program? ideally, i want to see all vars,

Re: Misleading Exception due to function name containing -

2011-09-11 Thread Jonathan Fischer Friberg
I've had no problems with functions containing - Jonathan On Fri, Sep 9, 2011 at 10:47 AM, Christina Conway ccon...@annadaletech.comwrote: A function name contains the characters - e.g. foo-fn The function causes an exception. However the exception is not reported on the function but on

Re: Exceptions in Haskell and in Clojure

2011-09-12 Thread Jonathan Fischer Friberg
Incidentally, I was just working on such a thing. I'll send it in a new thread. Jonathan On Sun, Sep 11, 2011 at 7:03 PM, Michael Jaaka michael.ja...@googlemail.com wrote: Couldn't match expected type `(t, t1)' against inferred type `(t2, t3, t4)' In the expression: (8, 11, 5) In the

trace-forms macro

2011-09-12 Thread Jonathan Fischer Friberg
Hello, I made a small macro, if anyone is interested. https://gist.github.com/1209498 It wraps one or more forms and if an exception is thrown, prints the form that caused it, and throws the exception itself. Examples: user= (trace-forms 3) 3 user= (trace-forms (+ 6 (/ 9 0)))

Re: heaps in clojure

2011-09-13 Thread Jonathan Fischer Friberg
There is the inbuilt sort function, also sort-by is useful. In The joy of clojure, there were an example of a lazy sort. It can be found here: http://www.manning.com/fogus/ In the file q.clj in the source code. Jonathan On Tue, Sep 13, 2011 at 1:44 PM, Sunil S Nandihalli

Re: trace-forms macro

2011-09-14 Thread Jonathan Fischer Friberg
It was tested with 1.2.1 Jonathan On Wed, Sep 14, 2011 at 9:09 AM, Sergey Didenko sergey.dide...@gmail.comwrote: Looks interesting. Did you use it with Clojure 1.3 or earlier? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Mocking out namespaces

2011-09-14 Thread Jonathan Fischer Friberg
You could call the mock file B_mock.clj then (require '[B-mock :as B]) Jonathan On Wed, Sep 14, 2011 at 5:19 PM, Brian Hurt bhur...@gmail.com wrote: Say I have two name spaces, A and B, with A depending on B. I want to test namespace A, replacing module B with a mock B for testing purposes-

Re: trace-forms macro

2011-09-24 Thread Jonathan Fischer Friberg
is still valuable for runtime tracing. Luc P. On Mon, 12 Sep 2011 11:31:39 +0200 Jonathan Fischer Friberg odysso...@gmail.com wrote: Hello, I made a small macro, if anyone is interested. https://gist.github.com/1209498 It wraps one or more forms and if an exception is thrown, prints

Re: trace-forms macro

2011-09-26 Thread Jonathan Fischer Friberg
I looked at it today and have updated the macro. (same gist: https://gist.github.com/1209498) Additions: It detects if a form contains (recur ...), and if it does, the form isn't wrapped in (try ...). trace vectors, maps, and sets. trace (fn* ...) (new ...) --- The code feels a bit thrown

Re: iterate with side-effect function?

2011-09-28 Thread Jonathan Fischer Friberg
How about while? (while not-finished (do stuff ...)) On Wed, Sep 28, 2011 at 4:23 AM, Nathan Sorenson n...@sfu.ca wrote: 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

Re: Learning clojure - comments on my function?

2011-09-29 Thread Jonathan Fischer Friberg
First of all, you should switch from ((fn [ls wip ans] ...) ls [] nil) to (loop [ls ls wip [] ans nil] ...) Read about it here: http://clojure.org/special_forms Using higher-order functions, you could do: (defn split-zero [coll] (if (seq coll) (let [divided (partition-by zero? coll)]

Re: goog.net.cookies with clojurescript?

2011-10-06 Thread Jonathan Fischer Friberg
I managed to do it. The problem is that we need to use the function set in a goog.net.Cookies object. There is already such an object, which is called goog.net.cookies, see the bottom of the source file: /** * A static default instance. * @type {goog.net.Cookies} */ goog.net.cookies = new

Re: clojure.contrib.base64

2011-10-06 Thread Jonathan Fischer Friberg
thus enable all Clojure developers to have lightning fast Base64 encoding/decoding? This is already possible, if you're using leiningen: put the file in src/util/ and compile, you can now call it as usual. On Thu, Oct 6, 2011 at 11:16 AM, Rok Lenarcic rok.lenar...@gmail.comwrote: I use

Re: The Website / Wikispaces

2011-10-06 Thread Jonathan Fischer Friberg
I do On Thu, Oct 6, 2011 at 2:32 PM, Simon Morgan s...@spamcop.net wrote: When using clojure.org does anybody else quite frequently get the Wikispaces homepage instead? This seems to happen most often when I start Firefox because I always have a clojure.org tab open. Any idea what's causing

Re: tools.logging vs clojure.contrib.logging

2011-10-12 Thread Jonathan Fischer Friberg
As I understand it, tools.logging was created from clojure.contrib.logging (but has been updated since). In any case; if there exists a library in clojure/, which can perform the same things as some part of contrib, use the clojure/ one. On Wed, Oct 12, 2011 at 5:06 PM, jingguo

Get the name of keyword/symbol in clojurescript

2011-10-17 Thread Jonathan Fischer Friberg
Hi, As I understand it, clojurescript uses some unicode characters to identify keywords/symbols. I guess that's why (str 'a) gives me ï·‘'a I thought that this was intentional, and that (name 'a) would give me a, but I got the same result as with (str). So how do I extract the name from a symbol

Re: Get the name of keyword/symbol in clojurescript

2011-10-18 Thread Jonathan Fischer Friberg
, browser REPL, etc.) ? David On Mon, Oct 17, 2011 at 6:41 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: Hi, As I understand it, clojurescript uses some unicode characters to identify keywords/symbols. I guess that's why (str 'a) gives me ï·‘'a I thought that this was intentional

Re: Get the name of keyword/symbol in clojurescript

2011-10-18 Thread Jonathan Fischer Friberg
this at the REPL (say via script/repljs) ? David On Tue, Oct 18, 2011 at 7:22 AM, Jonathan Fischer Friberg odysso...@gmail.com wrote: I'm on the master branch. I compiled the file using 'cljsc file file.js', and run it in the browser. On Tue, Oct 18, 2011 at 1:16 AM, David Nolen dnolen.li

Re: Get the name of keyword/symbol in clojurescript

2011-10-18 Thread Jonathan Fischer Friberg
, David Nolen dnolen.li...@gmail.comwrote: Does the same problem occur when trying this at the REPL (say via script/repljs) ? David On Tue, Oct 18, 2011 at 7:22 AM, Jonathan Fischer Friberg odysso...@gmail.com wrote: I'm on the master branch. I compiled the file using 'cljsc file file.js

Re: Get the name of keyword/symbol in clojurescript

2011-10-18 Thread Jonathan Fischer Friberg
It works! Thanks for all the help. On Tue, Oct 18, 2011 at 5:52 PM, David Nolen dnolen.li...@gmail.com wrote: I see you're not setting the encoding. Try adding the following to the top of head meta charset=UTF-8 David On Tue, Oct 18, 2011 at 11:43 AM, Jonathan Fischer Friberg odysso

Re: Merging two maps based on ids

2011-04-26 Thread Jonathan Fischer Friberg
(defn merge-data [data1 data2] (map first (partition-by :id (sort-by :id (concat data1 data2) Since the sorting is stable (relative order is kept), we know that the first occurrence of each id is either the existing map from data1, or the new map from data2. On Tue, Apr 26, 2011 at 5:34

Re: Merging two maps based on ids

2011-04-26 Thread Jonathan Fischer Friberg
Correction: (concat data1 data2) should be (concat data2 data1) On Tue, Apr 26, 2011 at 6:37 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: (defn merge-data [data1 data2] (map first (partition-by :id (sort-by :id (concat data1 data2) Since the sorting is stable (relative

Re: Odd Java interop behavior

2011-04-26 Thread Jonathan Fischer Friberg
Since you are essentially using java, I think that a clojure bug can be ruled out. Have you checked the drive for errors? On Tue, Apr 26, 2011 at 8:12 PM, Ken Wesson kwess...@gmail.com wrote: Anyone know what is going on here? I'm trying to use my Clojure REPL to rename a file that's gotten

Re: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
I don't know. However, given the situation I think (cond (empty? @unique-offers) (dosync ... alter ...) :else (logger/log error)) is better, since the change is more isolated. On Tue, Apr 26, 2011 at 9:45 PM, Zlatko Josic zlatko.jo...@gmail.comwrote: Hi, I use cond in dosync but it

Re: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
On a closer look: ((logger/log map @unique-offers) (alter unique-offers assoc offer-value streams)) should probably be (do (logger/log map @unique-offers) (alter unique-offers assoc offer-value streams)) On Tue, Apr 26, 2011 at 9:55 PM, Jonathan Fischer Friberg odysso

Re: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
unique-offers is old value but all-offers is new value? Thanks On Tue, Apr 26, 2011 at 9:55 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: I don't know. However, given the situation I think (cond (empty? @unique-offers) (dosync ... alter ...) :else (logger/log error

Re: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
its transaction wich puts values in both maps. Now first thread check second condition (empty? @map2) which is false. On Tue, Apr 26, 2011 at 10:17 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: The important part were that the dosync call is isolated. The condition doesn't

Re: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
Yes, you're right, I'm wrong. :) The derefs must be in the dosync block. (which I somehow assumed, oh well) On Tue, Apr 26, 2011 at 11:17 PM, Daniel Werner daniel.d.wer...@googlemail.com wrote: On Apr 26, 10:52 pm, Jonathan Fischer Friberg odysso...@gmail.com wrote: No, that isn't

Re: Executing Future

2011-04-28 Thread Jonathan Fischer Friberg
So I have this question. I have heard that Clojure's data structures are immutable and it has support for promises, agents, atoms etc. It's not that clojure's data structures support promises, agents ... It's more like promises, agents ... support clojure's data structures. Changing something in

Re: Monadic implementation of the Shunting-yard algorithm

2011-05-03 Thread Jonathan Fischer Friberg
I wrote a simple implementation: http://gist.github.com/953966https://gist.github.com/953966 (only supports operators) It's not very elegant (I don't know how to use fnparse..), but it is functional. What it does is find out what the next element in the operator stack and the out stack should be,

Re: Recreate a hierarchy

2011-05-05 Thread Jonathan Fischer Friberg
This is my take on this: http://gist.github.com/957028 The second file produces the correct result. The result isn't exactly like you asked for. This is because it wouldn't support files that isn't in the lowest level. Ex: (restore-hierarchy [[top level file1] [top level file2] [top level2

Re: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
= uses the clojure.lang.Util/equiv to compare two things. The source of this function is: [1] static public boolean equiv(Object k1, Object k2){ if(k1 == k2) return true; if(k1 != null) { if(k1 instanceof Number k2 instanceof

Re: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
to haven't changed in 1.3. Cheers, Dominikus On May 5, 4:27 pm, Jonathan Fischer Friberg odysso...@gmail.com wrote: = uses the clojure.lang.Util/equiv to compare two things. The source of this function is: [1] static public boolean equiv(Object k1, Object k2){ if(k1 == k2

Re: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
It also seems that I have been linking to the wrong repo... :S https://github.com/clojure/clojure Should be the correct one. On Thu, May 5, 2011 at 6:09 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: I'm also interested in that. I think it has to do with how clojure.lang.Compiler [1

Re: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
I created a new datatype to solve this problem: http://gist.github.com/958001 c-fn creates a comparable function; (let [fnmaker4 (fn [coll] (c-fn [n] (nth coll n))) ints (range)] (= (fnmaker4 ints) (fnmaker4 ints))) = true On Thu, May 5, 2011 at 10:41 PM, Alan a...@malloys.org wrote:

Re: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
Although (as I just realized), it fails miserably with closures. On Thu, May 5, 2011 at 11:38 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: I created a new datatype to solve this problem: http://gist.github.com/958001 c-fn creates a comparable function; (let [fnmaker4 (fn [coll

  1   2   >