http://mike.bobak.googlepages.com/clmath.txt on why cl has better intrisic math ability A quick snippet on why CL vs any of the others ------------------------- http://www.johnmyleswhite.com/notebook/2012/04/13/floating-point-arithmetic-and-the-descent-into-madness/ Julia, R, and Python all fail: 0.1 + 0.1 == 0.2 # True 0.1 + 0.1 + 0.1 == 0.3 # False 0.1 + 0.1 + 0.1 + 0.1 == 0.4 # True On my Intel Core 2 Duo machine running OS X, those statements have the indicated truth values in all three of Julia, R, and Python. = so I looked, and several languages screw this and other simple math up, even ones I've liked: = First to show that CL works: λ▶<4 28daedalus: /dm/graph> sbcl ;Showing that CommonLisp will work &understands fractions;) Sun Apr 29 20:17:37 PDT 2012 USER(1): (equal (+ 0.1 0.1) 0.2) T USER(2): (equal (+ 0.1 0.1 0.1) 0.3) T USER(3): (equal (+ 0.1 0.1 0.1 0.1) 0.4) T USER(4): USER(4): (/ 1 3) 1/3 USER(5): (lo) start:Sun Apr 29 20:17:44 PDT 2012 to-now:Sun Apr 29 20:19:52 PDT 2012 "byE" ==and now the languages that are not careful with numbers: λ▶<5 28daedalus: /dm/graph> clu CLIPS (V6.24 06/15/06) CLIPS> (/ 1 3) 0.333333333333333 CLIPS> (ex) Jess> (eq (+ 0.1 0.1) 0.2) TRUE Jess> (eq (+ 0.1 0.1 0.1) 0.3) FALSE Jess> (eq (+ 0.1 0.1 0.1 0.1) 0.4) TRUE Jess> Jess> (/ 1 3) 0.3333333333333333 Jess> user=> (= (+ 0.1 0.1) 0.2) true user=> (= (+ 0.1 0.1 0.1) 0.3) false user=> (= (+ 0.1 0.1 0.1 0.1) 0.4) true user=> (/ 1 3) 1/3 user=> Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 1 == 1 True >>> 0.1 + 0.1 == 0.2 True >>> 0.1 + 0.1 + 0.1 == 0.3 False >>> 0.1 + 0.1 + 0.1 + 0.1 == 0.4 True >>> 1 / 3 0 >>> clojure&sage sage are the only ones to take1step tword CL but still too far/still basic screw ups /j/clojure> clj Clojure 1.2.0 user=> (/ 1 3) 1/3 user=> (= (+ 0.1 0.1) 0.2) true user=> (= (+ 0.1 0.1 0.1) 0.3) false user=> (= (+ 0.1 0.1 0.1 0.1) 0.4) true user=> sage: http://localhost:8000/home/admin/0/ evaluate 1 == 1 True 0.1 + 0.1 == 0.2 True 0.1 + 0.1 + 0.1 == 0.3 False 0.1 + 0.1 + 0.1 + 0.1 == 0.4 True 1 / 3 1/3 sage also takes a baby step away from python etc ;ruby is just as bad as python &I'm sure perl/etc /msc/rr> irb >> s1 = "abc" => "abc" >> if "abc" == s1 >> puts 'they r eq' >> end they r eq => nil >> 1 == 1 => true >> 0.1 + 0.1 == 0.2 => true >> 0.1 + 0.1 + 0.1 == 0.3 => false >> 0.1 + 0.1 + 0.1 + 0.1 == 0.4 => true >> 1 / 3 => 0 >> puts 'ruby also looses for math ability' ruby also looses for math ability => nil >> even: > octave GNU Octave, version 3.4.0 Copyright (C) 2011 John W. Eaton and others. This is free software; see the source code for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'. Octave was configured for "x86_64-apple-darwin10.7.3". Additional information about Octave is available at http://www.octave.org. Please contribute if you find this software useful. For more information, visit http://www.octave.org/help-wanted.html Read http://www.octave.org/bugs.html to learn how to submit bug reports. For information about changes from previous versions, type `news'. octave-3.4.0:1> 0.1 + 0.1 == 0.2 ans = 1 octave-3.4.0:2> 0.1 + 0.1 + 0.1 == 0.3 ans = 0 octave-3.4.0:3> 0.1 + 0.1 + 0.1 + 0.1 == 0.4 ans = 1 octave-3.4.0:4> 1 / 3 ans = 0.33333 octave-3.4.0:5> =a matlab clone (&R below) can not even do what is 1st nature in cl R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > 0.1 + 0.1 == 0.2 [1] TRUE > 0.1 + 0.1 + 0.1 == 0.3 [1] FALSE > 0.1 + 0.1 + 0.1 + 0.1 == 0.4 [1] TRUE > 1 / 3 [1] 0.3333333 > -more problems coming from jvm: Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31). Type in expressions to have them evaluated. Type :help for more information. scala> 1 == 1 res0: Boolean = true scala> 0.1 + 0.1 == 0.2 res1: Boolean = true scala> 0.1 + 0.1 + 0.1 == 0.3 res2: Boolean = false scala> 0.1 + 0.1 + 0.1 + 0.1 == 0.4 res3: Boolean = true scala> 1 / 3 res4: Int = 0 scala> -comes from C: #include main () { if ( (0.1 + 0.1) == 0.2) putc('2',stdout); if ( (0.1 + 0.1 + 0.1) == 0.3) putc('3',stdout); if ( (0.1 + 0.1 + 0.1 + 0.1) == 0.4) putc('4',stdout);} c> ./tm 24 ==endnotes: I'm intersted to look more at http://www.isle.org/process/ which benefits from Lisp in many ways. also worth looking at: http://nostoc.stanford.edu/Docs/ now: http://biobike.csbc.vcu.edu/