Re: is mod correct?

2009-02-12 Thread Frantisek Sodomka
Also, mod seems too strict about numbers it accepts (only integers!): user= (rem 1 2/3) 1/3 user= (mod 1 2/3) java.lang.IllegalArgumentException: mod requires two integers (NO_SOURCE_FILE:0) user= (rem 4.5 2.0) 0.5 user= (mod 4.5 2.0) java.lang.IllegalArgumentException: mod requires two

Trojan horse in our Files section

2009-02-14 Thread Frantisek Sodomka
My antivirus doesn't like the Gift from the Stranger: http://groups.google.com/group/clojure/files?sort=date Not really nice of you, Stranger... Frantisek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure

Re: Bugs in set and sorted-set (?)

2009-02-14 Thread Frantisek Sodomka
Similar is: user= #{[] ()} #{[]} user= #{[] [1 2]} #{[] [1 2]} user= (hash-set [] ()) #{[]} Frantisek On Feb 15, 12:38 am, Frantisek Sodomka fsodo...@gmail.com wrote: Hello! Function 'set' looses some of its data. It seems that there is a problem with comparison between lists and vectors

Re: Bugs in set and sorted-set (?)

2009-02-15 Thread Frantisek Sodomka
It is making more sense now. One other interesting thing that surprised me is: There is not a total ordering across types. See discussion: http://groups.google.com/group/clojure/browse_frm/thread/710848919c68981f/51ede18b2fd7ab96?lnk=gstq=sorted-set#51ede18b2fd7ab96 Therefore things like (sort

Re: Fully lazy sequences are here!

2009-02-17 Thread Frantisek Sodomka
That was fast! ;-) Rich, I am porting test_clojure and old 'cycle' worked as: (cycle []) = nil Currently: (cycle []) = java.lang.StackOverflowError Frantisek On Feb 17, 8:43 pm, Rich Hickey richhic...@gmail.com wrote: I've merged the lazy branch into trunk, SVN rev 1287 Please do not rush

'nil 'false 'true - symbols or Clojure keywords?

2009-02-17 Thread Frantisek Sodomka
Usual symbol: 'abc = abc (symbol? 'abc) = true (symbol abc) = abc (symbol? (symbol abc)) = true Special symbol: 'nil = nil (symbol? 'nil) = false (symbol nil) = nil (symbol? (symbol nil)) = true (= 'nil (symbol nil)) = false (= 'nil nil) = true We can see that (symbol nil) truly evaluates to

Re: Fully lazy sequences are here!

2009-02-18 Thread Frantisek Sodomka
There is something that confuses me: user= (cycle []) () user= (= (cycle []) ()) true user= (= (cycle []) nil) true user= (= () nil) false Thanks for answering, Frantisek On Feb 18, 3:54 am, Rich Hickey richhic...@gmail.com wrote: On Feb 17, 4:16 pm, Frantisek Sodomka fsodo...@gmail.com

Re: Fully lazy sequences are here!

2009-02-18 Thread Frantisek Sodomka
I believe it's already done. Frantisek On Feb 18, 12:39 pm, Mark Volkmann r.mark.volkm...@gmail.com wrote: Now that next is recommended over rest, should nthrest be renamed to nthnext? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You

Re: Fully lazy sequences are here!

2009-02-18 Thread Frantisek Sodomka
What about 'conj'? Documentation says: (conj nil item) returns (item). Currently: user= (conj nil 1) (1) user= (conj () 1) (1) Idiom conj nil is used in 'reverse': (reduce conj nil coll) Currently: user= (reverse [1 2]) (2 1) user= (reverse [1]) (1) user= (reverse []) nil It looks that now all

Re: Fully lazy sequences are here!

2009-02-18 Thread Frantisek Sodomka
Or maybe more general question: Is there any function in Clojure which when returning empty sequence, returns nil instead of () ??? user= (butlast [1 2 3]) (1 2) user= (butlast [1]) nil user= (butlast []) nil Thanks, Frantisek On Feb 18, 5:46 pm, Frantisek Sodomka fsodo...@gmail.com wrote

Re: bug affecting clojure.core/bean?

2009-02-18 Thread Frantisek Sodomka
Or maybe: next ??? :- Frantisek On Feb 18, 5:27 pm, Rich Hickey richhic...@gmail.com wrote: On Feb 18, 11:04 am, Chouser chou...@gmail.com wrote: On Wed, Feb 18, 2009 at 12:35 AM, Rob rob.nikan...@gmail.com wrote: I'm wondering if I found a bug.  I have the latest source from svn

Re: Fully lazy sequences are here!

2009-02-18 Thread Frantisek Sodomka
On Feb 18, 5:58 pm, Chouser chou...@gmail.com wrote: On Wed, Feb 18, 2009 at 11:46 AM, Frantisek Sodomka fsodo...@gmail.com wrote: What about 'conj'? Documentation says: (conj nil item) returns (item). Currently: user= (conj nil 1) (1) user= (conj () 1) (1) Is there something

Re: Fully lazy sequences are here!

2009-02-18 Thread Frantisek Sodomka
:02 pm, Rich Hickey richhic...@gmail.com wrote: On Feb 18, 12:20 pm, Frantisek Sodomka fsodo...@gmail.com wrote: How should I say it... It just didn't look symmetrical to me. So, basically, there is a difference between functions returning sequences - depending on if they are lazy or eager

Possible bug in sorted-set, question about comparisons

2009-02-20 Thread Frantisek Sodomka
sorted-set works for vectors, but doesn't work for lists, maps and sets: user= (sorted-set [1 4]) #{[1 4]} user= (sorted-set [1 4] [1 4]) #{[1 4]} user= (sorted-set [4 1] [1 4]) #{[1 4] [4 1]} user= (sorted-set '(1 4)) #{(1 4)} user= (sorted-set '(1 4) '(1 4)) java.lang.ClassCastException:

Re: Possible bug in sorted-set, question about comparisons

2009-02-20 Thread Frantisek Sodomka
that implements Comparable. user= (instance? Comparable []) true user= (instance? Comparable {}) false user= (instance? Comparable ()) false user= On Feb 20, 2:21 pm, Frantisek Sodomka fsodo...@gmail.com wrote: sorted-set works for vectors, but doesn't work for lists, maps and sets

Re: Possible bug in sorted-set, question about comparisons

2009-02-20 Thread Frantisek Sodomka
object: user (sorted-set '(1) '(1)) ; Exception user (let [x '(1)] (sorted-set x x)) #{(1)} This is almost certainly not documented behavior and should not be relied upon. Cheers, Jason On Feb 20, 11:42 am, Frantisek Sodomka fsodo...@gmail.com wrote: It looks that it is more

Re: where is contrib?

2009-02-21 Thread Frantisek Sodomka
For example, lazy-cons is still present in: combinatorics.clj lazy_xml/with_pull.clj monads/examples.clj Frantisek On 21 Ún, 15:54, James Reeves weavejes...@googlemail.com wrote: On Feb 21, 2:36 pm, bOR_ boris.sch...@gmail.com wrote: Note that clojure just changed the lazy branch to be the

nth with regex Matchers

2009-02-21 Thread Frantisek Sodomka
nth claims to also work on regex Matchers: user= (doc nth) - clojure.core/nth ([coll index] [coll index not-found]) Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for

Should (pop nil) throw an exception?

2009-02-21 Thread Frantisek Sodomka
Hello! Currently, 'pop' throws an exception if the collection is empty: clojure.core/pop ([coll]) For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector without the last item. If the collection is empty, throws an exception. Note - not the

Re: clojure class hierarchy

2009-02-21 Thread Frantisek Sodomka
You can read: http://clojure.org/data_structures http://clojure.org/sequences and: http://en.wikibooks.org/wiki/Clojure_Programming Frantisek On 21 Ún, 22:24, linh nguyenlinh.m...@gmail.com wrote: where can i find information about clojure's data-structure class hierarchy? i would like to

Issue 52 looks solved

2009-02-22 Thread Frantisek Sodomka
Hello! Just a quick note: Issue 52: Make set/union accept any number of arguments http://code.google.com/p/clojure/issues/detail?id=52 seems to be solved already by: SVN 1276 http://code.google.com/p/clojure/source/detail?r=1276 added multi-arg clojure.set/union/difference/intersection, patch

Re: nth with regex Matchers

2009-02-22 Thread Frantisek Sodomka
Frantisek On 22 Ún, 02:37, Chouser chou...@gmail.com wrote: On Sat, Feb 21, 2009 at 1:34 PM, Frantisek Sodomka fsodo...@gmail.com wrote: nth claims to also work on regex Matchers: user= (doc nth) - clojure.core/nth ([coll index] [coll index not-found])  Returns

Re: Should (pop nil) throw an exception?

2009-02-22 Thread Frantisek Sodomka
Any thoughts on this one? Impatient Frantisek :-) On 21 Ún, 22:28, Frantisek Sodomka fsodo...@gmail.com wrote: Hello! Currently, 'pop' throws an exception if the collection is empty: clojure.core/pop ([coll])   For a list or queue, returns a new list/queue without the first   item

Re: Directed Graphs for Contrib

2009-02-22 Thread Frantisek Sodomka
Graphs has always inspired me and seeing implementation in Clojure will be no less inspiring. http://www.visualcomplexity.com/vc/ http://planarity.net/ Frantisek On 22 Ún, 16:11, Jeffrey Straszheim straszheimjeff...@gmail.com wrote: Just as a point of fact, I don't plan to make a complete

Re: Changed clojure.contrib.test-clojure to load without running, add run method

2009-02-23 Thread Frantisek Sodomka
On Feb 23, 12:12 am, Stephen C. Gilardi squee...@mac.com wrote: On Feb 22, 2009, at 5:41 PM, Frantisek Sodomka wrote: There was a functionality in build.xml to run tests from the command line. When you correctly set clojure.jar path, you could just do: ant test_clojure Fixed. Thanks

Re: 6 + 7 = 13

2009-02-24 Thread Frantisek Sodomka
I see only 6 + 36 = 42 Frantisek On Feb 24, 11:25 am, Marko marko.van.doo...@gmail.com wrote: Hi, just reporting an error on the following page:http://clojure.org/dynamic 6 + 7 should really be 13, and not 42. --~--~-~--~~~---~--~~ You received this message

Re: bug? ClassNotFoundException from macro

2009-02-25 Thread Frantisek Sodomka
I get different error (running from REPL): (test2 (+ 1 1)) = java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0) (test2 10) = java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0) I think that it has to do with 'test1' in your macro. Function 'test1' gets compiled into a Java class and

Re: test-clojure: eval failure

2009-03-02 Thread Frantisek Sodomka
Hmm, interesting error. After the merge of the lazy branch was everything ok, so it has to be a recent change. user= (eval (list + 1 2 3)) java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0) user= (eval '(+ 1 2 3)) 6 user= (list + 1 2 3) (#core$_PLUS___243 clojure.core$_plus___...@153f141

test-clojure: trouble with the latest Clojure SVN version

2009-03-03 Thread Frantisek Sodomka
There is a problem with the latest Clojure SVN version. Try running in clojure-contrib: ant test_clojure It generates failures and errors. There is some confusion between nil and () by the reader/compiler it seems. Also: user= (pop '(1 2 3)) java.lang.ClassCastException:

Re: New mod code is broken

2009-03-12 Thread Frantisek Sodomka
Latest SVN r1327 works ok: user= (mod 9 -3) 0 user= (map #(mod % 3) (range -10 10)) (2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0) Test-clojure runs ok too. Frantisek On Mar 12, 10:30 am, bOR_ boris.sch...@gmail.com wrote: Mod seems to have broken again (mod 9 -3)  gives -3 (map #(mod % 3)

Behavior of 'empty'

2009-03-16 Thread Frantisek Sodomka
Hello Rich all! I am digging into behavior of function 'empty': user= (doc empty) - clojure.core/empty ([coll]) Returns an empty collection of the same category as coll, or nil (empty [1 2]) = [] (empty (seq [1 2])) = nil (empty '(1 2)) = () (empty (seq '(1 2))) = ()

Re: Improving the test suite

2009-03-17 Thread Frantisek Sodomka
Hello Phil, I see that you have your CA in already: http://clojure.org/contributing so you can start with creating issues and posting patches for them: http://code.google.com/p/clojure-contrib/issues/list Then somebody from clojure-contrib members looks at it and eventually checks it in.

Re: Behavior of 'empty'

2009-03-17 Thread Frantisek Sodomka
: On Mar 16, 7:13 pm, Mark Engelberg mark.engelb...@gmail.com wrote: On Mon, Mar 16, 2009 at 3:54 PM, Frantisek Sodomka fsodo...@gmail.com wrote: (empty (seq [1 2])) = nil Now that there is the concept of empty sequences, maybe this should actually return an empty sequence, such as (). Yes

Reading decimal numbers (doubles)

2009-03-17 Thread Frantisek Sodomka
Hello Rich all! I have question about the reader http://clojure.org/reader Numbers say as per Java. I found that e.g. 2. reads Java as double and Clojure as int. All these read as double in Java: 2. .1 +.0 -.0 +2. -2. Clojure either sees them as ints or errors out. I am wondering about

Re: Possible Bug In clojure.zip/remove

2009-03-19 Thread Frantisek Sodomka
On Mar 19, 12:58 pm, Jason Sankey ja...@zutubi.com wrote: Also, is there somewhere I can contribute test cases for this to prevent a future regression? In order to contribute, you must fill-in and send The Contributor Agreement (CA) to Rich Hickey: http://clojure.org/contributing Tests for

Re: Improving the test suite

2009-03-19 Thread Frantisek Sodomka
Test-clojure is updated and ready for new tests :-) Frantisek On Mar 17, 5:03 am, Phil Hagelberg p...@hagelb.org wrote: OK, so I've posted a fair amount of smack talk about test suites and how important they are--I figure it's time to help out. What are some ways in which test-clojure is

test-is: new feature suggestion

2009-03-19 Thread Frantisek Sodomka
Hello Stuart all! As discussed in this thread: test-is: generating and processing testing data http://groups.google.com/group/clojure/browse_frm/thread/3e84efefd7c0bebc/3652a4a9a124cc6b , sometimes it is necessary to test each value against each value. Example is zeros-are-equal (as you

Re: test-is: new feature suggestion

2009-03-20 Thread Frantisek Sodomka
On Mar 19, 11:08 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: Hi Frantisek! I can see where this is useful, and the only reason I haven't implemented something like it for a test-is already is that I don't expect it would be very commonly used outside of the very specific case of

Re: Possible Bug In clojure.zip/remove

2009-03-20 Thread Frantisek Sodomka
On Mar 19, 11:37 pm, Jason Sankey ja...@zutubi.com wrote: I pretty much have it working for the test-clojure suite now, although I'm sure the code could use review by a more experienced eye.  I've been looking at adding the other two top-level suites (test-contrib and datalog) too, but their

Re: Possible Bug In clojure.zip/remove

2009-03-22 Thread Frantisek Sodomka
On Mar 19, 12:58 pm, Jason Sankey ja...@zutubi.com wrote: Also, is there somewhere I can contribute test cases for this to prevent a future regression? Tests for clojure.zip can from now on go to test-clojure.clojure-zip:

Behavior of clojure.set/union and hinting function arguments

2009-03-22 Thread Frantisek Sodomka
Hello Rich everybody! clojure.set/union currently accepts 'nil' as a valid argument: (union nil) = nil (union nil nil) = nil (union nil #{1 2}) = #{1 2} (union #{1 2} nil) = #{1 2} (union #{} nil) = #{} (union nil #{}) = nil ; not consistent Possible solution would be to ban 'nil' as

Re: I'm experimenting clojure - sorted-set-by?

2009-03-24 Thread Frantisek Sodomka
Hello! Yes, you are right, sorted-set-by is missing. Good news is - it is on the way :-) See issue 76: http://code.google.com/p/clojure/issues/detail?id=76 Frantisek On Mar 24, 5:35 am, hjlee hj.d@gmail.com wrote: Hi, all. I don't know why my previous posts ignored. spam filtering? so

Minor bug in int-array, long-array, float-array and double-array

2009-05-18 Thread Frantisek Sodomka
It looks that there is a bug in int-array, long-array, float-array and double-array when creating an array using an empty sequence. Doc: clojure.core/int-array ([size-or-seq] [size init-val-or-seq]) Creates an array of ints This works: user= (int-array 0) #int[] [...@11978b user= (vec

Re: Minor bug in int-array, long-array, float-array and double-array

2009-05-18 Thread Frantisek Sodomka
Sorry, forgot to mention: Found when testing Clojure 1.0.0. Frantisek --~--~-~--~~~---~--~~ 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

Re: svn r1370 appears to have broken binding

2009-05-25 Thread Frantisek Sodomka
Hello Steve! When I write a test for binding for this case (using deftest) and run test_clojure, it doesn't error out. I wonder why is that? (def a) (deftest test-binding (are (= _1 _2) (binding [a 4] a) 4 ; regression in Clojure SVN r1370 )) Frantisek PS: Rich, have you seen my

Re: Contributing tests

2009-06-05 Thread Frantisek Sodomka
Hello Richard, any contributions to test_clojure are very welcome! As a general rule to contribute, you need to fill-in and mail the CA: http://clojure.org/contributing When Rich receives your CA and updates the clojure.org website, you can start creating issues in clojure-contrib and attaching

Clojure performance and timings

2009-06-11 Thread Frantisek Sodomka
Hello all! After reading this article: Clojure performance tips http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/ I wrote a macro to better compare different timings of functions and expressions: (defmacro time-ms [n expr] `(let [start# (. System (nanoTime))] (dotimes

debugging, logging, ... and code sections

2008-08-31 Thread Frantisek Sodomka
Hello! It is very common pattern to include parts of code which are used for specific purposes - for example debugging, logging, etc. While these parts can be used when developing code, they can be removed from finished application. One way is to comment these parts out, when we are done.

Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))

2008-11-10 Thread Frantisek Sodomka
Hello, I would like to contribute to testing Clojure. (Rich has my CA already.) I have been thinking about it and going through some unit tests for different language. I am proposing this syntax change to macro 'is': Instead of writing: (deftest test-+ (is (= (+) 0)) (is (= (+ 1) 1))

Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))

2008-11-13 Thread Frantisek Sodomka
Using this, test t-Symbols (deftest t-Symbols (is (= 'abc (symbol abc))) (is (= '*+!-_? (symbol *+!-_?))) (is (= 'abc:def:ghi (symbol abc:def:ghi))) (is (= 'abc/def (symbol abc def))) (is (= 'abc.def/ghi (symbol abc.def ghi))) (is (= 'abc/def.ghi (symbol abc def.ghi))) (is

Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))

2008-11-13 Thread Frantisek Sodomka
On Thu, 13 Nov 2008 16:35:52 +0100, Dave Newton [EMAIL PROTECTED] wrote: --- On Thu, 11/13/08, Frantisek Sodomka wrote: [...] becomes: (deftest t-Symbols (check (:equal 'abc (symbol abc) '*+!-_? (symbol *+!-_?) 'abc:def:ghi (symbol abc:def:ghi

Re: clojure.contrib.test-is changes

2008-11-17 Thread Frantisek Sodomka
Thanks Stuart! It will certainly make writing tests more enjoyable :-) Inspiration for :equal-pairs/each= came from the test framework I wrote for newLISP: http://newlisp-on-noodles.org/wiki/index.php/Function_Testing Tests there are written as each= with 2 exceptions: '-' evaluates the next

Re: clojure.contrib.test-is changes

2008-11-17 Thread Frantisek Sodomka
Thinking about test-is little more... Lets look at this test for minus: (deftest test-minus (all-true (number? (- 1 2)) (integer? (- 1 2)) (float? (- 1.0 2)) (ratio? (- 2/3 1)) (float? (- 2/3 (/ 1.0 3 (throws IllegalArgumentException (-)) (each= (- 1)

Testing Clojure - progress sign up

2008-11-23 Thread Frantisek Sodomka
Hello all! I started writing some unit tests for Clojure. This is what I got so far: http://intricatevisions.com/source/clojure/fs_test_clojure.clj I am almost done with 'first' and 'rest'. I will do ffirst, frest, rfirst, rrest, second. Since I did 'if', I would also like to do 'and' and

Re: clojure.contrib.test-is: first major rewrite

2008-12-08 Thread Frantisek Sodomka
2. each= and all-true are gone, replaced by the new macro are, which works with any predicate: (are = 2 (+ 1 1) 4 (+ 2 2)) -Stuart Sierra Hello and thanks for additions! Happy to see additions and work done on tests :-) I just wonder - how do you define all-true using

Functional Geometry

2008-12-15 Thread Frantisek Sodomka
Hello all! I ported beatiful functional geometry: http://www.frank-buss.de/lisp/functional.html http://intricatevisions.com/index.cgi?page=nlcodetk into Clojure: http://intricatevisions.com/source/clojure/fg.clj (link from the page http://intricatevisions.com/index.cgi?page=clojure) When you

Re: Streams work

2009-01-21 Thread Frantisek Sodomka
Hello Rich, Looking forward to using them! It is pleasure to see such nice development! Frantisek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Streams work

2009-01-24 Thread Frantisek Sodomka
Word streams invokes association to data-flow languages. For a while, I was following Project V: Simple Example of the Difference Between Imperative, Functional and Data Flow. http://my.opera.com/Vorlath/blog/2008/01/06/simple-example-of-the-difference-between-imperative-functional-and-data-flow

Re: changes to test_clojure and test_contrib

2009-01-25 Thread Frantisek Sodomka
I have some tests ready for test_clojure. I asked Rich for SVN access rights. There is gonna be more tests soon :-) Frantisek On Sun, Jan 25, 2009 at 8:55 PM, Stuart Halloway stuart.hallo...@gmail.comwrote: In SVN 412 I have made the following changes to contrib: * a test_contrib.clj file

Re: changes to test_clojure and test_contrib

2009-01-28 Thread Frantisek Sodomka
Hello Steve, I attached file predicates.patch for type and number predicates. Let me know, if this is an acceptable patch (I haven't worked with them before). We can then create an issue for Clojure-contrib if necessary. Shawn, I keep wondering where is the best place to put tests for bug fixes.

New functions and possible bugs

2009-01-28 Thread Frantisek Sodomka
Hello all! During writing tests for type predicates, I noticed that these - possibly useful - predicates are not in clojure.core: boolean? character? regex? array? Since this is correct: user= (= () []) true Shouldn't these be also 'true'? user= (= {} []) false user= (= {} #{}) false user= (=

Re: New functions and possible bugs

2009-01-28 Thread Frantisek Sodomka
http://www.devguru.com/Technologies/ecmascript/quickref/javascript_index.html Frantisek On Jan 28, 9:17 pm, Cosmin Stejerean cstejer...@gmail.com wrote: On Wed, Jan 28, 2009 at 11:13 AM, Frantisek Sodomka fsodo...@gmail.comwrote: [...] Since this is correct: user= (= () []) true

test-is: generating and processing testing data

2009-01-28 Thread Frantisek Sodomka
Hello, I have suggestion about clojure.contrib.test-is. It is useful and sometimes necessary to generate testing data. Currently, data can be generated by a piece of code and passed to an 'is' function. For example, I want to test for equality of many things, to see if each is equal to each:

Re: test-is: generating and processing testing data

2009-01-28 Thread Frantisek Sodomka
Oops, error. Sequence passed to 'are' cannot be evaluated = use quoted list '( or quoted vector '[ ... (are (= _1 _2) '(3 (+ 1 2) 0 (+ -1 1))) Hm... Since 'are' is basically creating bunch of 'is' tests, I wonder how to also add a description message for each test. Thinking along the

Re: test-is: generating and processing testing data

2009-01-29 Thread Frantisek Sodomka
Thank you for explanation. I will use is for tests with messages. Otherwise, I am quite happy with are macro. It really helps with not repeating myself. I created 3 new issues and added 2 patches: http://code.google.com/p/clojure-contrib/issues/list Issue for sequences is to inform that I am

Re: Bug? overflow check in Numbers.minus

2009-01-29 Thread Frantisek Sodomka
user= (- Integer/MAX_VALUE Integer/MIN_VALUE) java.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0) user= (- Long/MAX_VALUE Long/MIN_VALUE) java.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0) Is this behavior correct? Frantisek On Jan 10, 5:25 am, Chouser

Re: SVN branches

2009-02-04 Thread Frantisek Sodomka
Streams were also intended for I/O. Is lazier addition also able to cope with I/O sucessfully? Can we have both - streams and lazy-seq? My thought about streams is that if they get included, they could be looked at as unsafe operations in Java/C# or unchecked math operations - as long as

test-is: (is (thrown? ...)) exceptions REPL

2009-02-05 Thread Frantisek Sodomka
Hello Stuart and all! There is something strange going on with (is (thrown? ...)) form: user= (use 'clojure.contrib.test-is) nil user= (is (= 2 2)) true ; this works user= (/ 1 0) java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:0) user= (is (thrown? ArithmeticException (/ 1 0)))

Re: test-is: (is (thrown? ...)) exceptions REPL

2009-02-05 Thread Frantisek Sodomka
user= (deftest test-if (is (thrown? Exception (if java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:35) user= (deftest test-div (is (thrown? ArithmeticException (/ 1 0 #'user/test-div Yes, looks like it. Compile-time and run-time exceptions - will have to remember that ;-)

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-08 Thread Frantisek Sodomka
If result is a vector v, then from these 4 cases: (let [v [1 2 3]] (let [[a b c] v] a b c) (let [a (v 0) b (v 1) c (v 2)] a b c) (let [a (nth v 0) b (nth v 1) c (nth v 2)] a b c) (let [x (first v) r1 (rest v) y (first r1) r2 (rest r1) z (first r2)] x y z)) using 'nth' (let [a (nth v 0) b

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-08 Thread Frantisek Sodomka
...@gmail.com wrote: On Wed, Jul 8, 2009 at 3:42 AM, Frantisek Sodomka fsodo...@gmail.comwrote: If result is a vector v, then from these 4 cases: (let [v [1 2 3]]  (let [[a b c] v] a b c)  (let [a (v 0) b (v 1) c (v 2)] a b c)  (let [a (nth v 0) b (nth v 1) c (nth v 2)] a b c)  (let [x (first v

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-08 Thread Frantisek Sodomka
So far it seems that vectors win in Clojure: (timings 3e5 (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth v 2)] (+ a b c)) (let [lst (list 1 2 3) a (nth lst 0) b (nth lst 1) c (nth lst 2)] (+ a b c))) = 680.63 ms 83.6% 1.2x (let [v (vector 1 2 3) a (nth v 0) b (nth v 1) c (nth

Re: Passing primitives from an inner loop to an outer loop efficiently

2009-07-09 Thread Frantisek Sodomka
, it looks that list creation is faster than vector creation. Frantisek On Jul 9, 12:17 am, John Harrop jharrop...@gmail.com wrote: On Wed, Jul 8, 2009 at 4:57 PM, Frantisek Sodomka fsodo...@gmail.comwrote: So far it seems that vectors win in Clojure: (timings 3e5  (let [v (vector 1 2 3

Re: Performance question (newbie)

2009-07-15 Thread Frantisek Sodomka
If you make it into a function and use type hints, that should help: (defn sum [n] (let [n (int n)] (loop [ret (long 0) i (int 1)] (if ( i n) (recur (+ ret i) (inc i)) ret user= (time (reduce + (range 1 100))) Elapsed time: 116.959837 msecs 4950

Re: Performance question (newbie)

2009-07-15 Thread Frantisek Sodomka
PS: Read tips on: http://clojure.org/java_interop On Jul 15, 1:51 pm, Dragan draga...@gmail.com wrote: Hi, I am trying to compare the performance of java loops to clojure reduce function. Noting special, Since I am just learning. Java code is something like: [code] long sum = 0; for

Compiler bug?

2013-06-06 Thread Frantisek Sodomka
Hi all, I am trying new parsing library Instaparse. I setup a Leiningen project, included [instaparse 1.1.0] as my dependency and tried to run it. Unfortunately, I am getting this error: Exception in thread main java.lang.NoClassDefFoundError: instaparse/print$parser__GT_str (wrong name:

Re: Compiler bug?

2013-06-10 Thread Frantisek Sodomka
Thank you for the fix, now it works without the problem. It's fun to write grammars with Instaparse :-) On Friday, June 7, 2013 1:29:32 AM UTC+2, puzzler wrote: On Thu, Jun 6, 2013 at 4:27 PM, Mark Engelberg mark.en...@gmail.comjavascript: wrote: Short answer: This is fixed in

Re: [ANN] Instaparse 1.1.0

2013-06-10 Thread Frantisek Sodomka
Hello Mark, I have few suggestions: 1. I was going through the tutorial and comparing EBNF and ABNF grammars. ABNF adds Bounded Repetition 3*5 A. Is there any chance of adding it also to EBNF? I don't know, how the syntax would be, but it can be useful at times. Repetition of characters can be

Re: [ANN] Instaparse 1.1.0

2013-06-10 Thread Frantisek Sodomka
EBNF syntax for bounded repetition could be just simply A 3*5 and these are equal: A? is A*1 A+ is A1* A* is A0* Frantisek On Monday, June 10, 2013 11:04:52 AM UTC+2, Frantisek Sodomka wrote: Hello Mark, I have few suggestions: 1. I was going through the tutorial and comparing EBNF

Re: [ANN] Instaparse 1.1.0

2013-06-10 Thread Frantisek Sodomka
10, 2013 at 2:13 AM, Frantisek Sodomka fsod...@gmail.comjavascript: wrote: EBNF syntax for bounded repetition could be just simply A 3*5 and these are equal: A? is A*1 A+ is A1* A* is A0* Right now, in the EBNF syntax, numbers are valid non-terminal identifiers. So for example

Re: [ANN] Instaparse 1.1.0

2013-06-10 Thread Frantisek Sodomka
I am just curious, not requesting this feature :-) How to represent negation in BNF? http://stackoverflow.com/questions/10922352/how-to-represent-negation-in-bnf http://pythonhosted.org/modgrammar/libref.html modgrammar.EXCEPT(grammar, exc_grammar, **kwargs) Match grammar, but only if it

Re: Logos - core.logic

2011-05-04 Thread Frantisek Sodomka
Hello David, thanks for your work. It is very interesting addition. One thing that came to my mind, is a language Mercury: http://en.wikipedia.org/wiki/Mercury_(programming_language) http://www.mercury.csse.unimelb.edu.au/ Mercury is a new logic/functional programming language, which combines

Timing expressions and comparing results

2013-06-29 Thread Frantisek Sodomka
Hi all, If you need to compare running times of different expressions, you could use 'timings' macro: https://gist.github.com/fsodomka/5890711 It takes the number of runs and expressions to time. For example: user= (timings 1e7 (+ 1 2 3 4) (+ 1 (+ 2 (+ 3 4 [{:time 55.028223, :expr (+ 1 2 3

Re: Performance Patterns

2013-07-15 Thread Frantisek Sodomka
For my own needs, I wrote a macro 'timings' - see Timing expressions and comparing results: https://groups.google.com/d/msg/clojure/o8pOLc6uxQQ/bui7sJ-F5_wJ Code and examples are here: https://gist.github.com/fsodomka/5890711 Your examples on my machine with Clojure 1.5.1: (report (let [x 2 y

Re: wally: a alternative way to discover functions

2013-09-06 Thread Frantisek Sodomka
Hello, this gist does the similar thing: https://gist.github.com/jaked/6084411 Maybe you can find some inspiration in it. Frantisek On Thursday, September 5, 2013 11:23:28 PM UTC+2, Islon Scherer wrote: Hey guys, I don't know about you but when I was a beginner in Clojure (and it still

Re: [ANN] Clojure 1.7.0-alpha2

2014-09-08 Thread Frantisek Sodomka
Hello, I posted a question about volatiles on the github commit: https://github.com/clojure/clojure/commit/60440977823752f13a3fec3637538e9a1d68c5d4 I don't know if anybody noticed, so... why is volatile created with function volatile! and not volatile ? Atoms, refs and agents don't have

Re: [ANN] Clojure 1.7.0-alpha2

2014-09-11 Thread Frantisek Sodomka
Using my timings macro: https://gist.github.com/fsodomka/5890711 I am getting that: - creation derefing is 60% faster - swapping is 25% faster - resetting is about the same ;; volatile vs. atom ;; (report (timings 1e7 (deref (volatile! 42)) (deref (atom 42 ; |

Re: [ANN] Clojure 1.7.0-alpha2

2014-09-11 Thread Frantisek Sodomka
| ; | (do (atom 42) nil) | 72.237439 | 3.16 | 100.0 | On Thursday, September 11, 2014 11:06:44 AM UTC+2, Frantisek Sodomka wrote: Using my timings macro: https://gist.github.com/fsodomka/5890711 I am getting that: - creation derefing is 60% faster - swapping is 25% faster - resetting