[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Padding/placeholders (hashes) in numerical syntax



Sorry, forgot to attach.

On Sun, 04 Sep 2011 12:56:59 -0400, Aaron W. Hsu <arcfide@x> wrote:

On Sun, 04 Sep 2011 11:28:46 -0400, Peter Bex <Peter.Bex@x> wrote:

Outputs of other Schemes would be interesting to see as well, and
suggestions for new testcases are welcome too!

I have attached the results for Chez Scheme 8.3 (R6RS). I had to make some
basic modifications to the prelude, but I also had to change the test in
the macro (and res (nan? res) ...) to (and (real? res) (nan? res) ...)
because Chez Scheme's NAN? only accepts REAL? values.

There were 18 errors in total, all of them, as far as I can see, relating
to accepting prefix based numbers that the test says should error out. I'm
not sure I would argue that this is a bad thing.

As you can see from the outputs, the "errors" in these Schemes are mostly
related to padding syntax, and especially such gems like "#x1#+1#i" or
"#e1#/2".  Surprisingly, there's also lots of errors related to allowing
the decimal syntax for bases other than 10 (especially in Racket).

Chez doesn't appear to have any errors related to the padding, but it does
exhibit the same flexibility that Racket has regarding these decimal
syntaxes.

	Aaron W. Hsu



--
Programming is just another word for the lost Art of Thinking.
Chez Scheme Version 8.3
Copyright (c) 1985-2011 Cadence Research Systems


-> Simple integers
-----------------------------------------------------
OK                  ("1" 1)
OK                  ("+1" 1 "1")
OK                  ("-1" (- 1))
OK                  ("#i1" 1.0 "1.0" "1.")
OK                  ("#i-1" (- 1.0) "-1.0" "-1.")
OK                  ("-#i1" #f)
OK                  ("+-1" #f)
OK                  ("" #f)
OK                  ("-" #f)
OK                  ("+" #f)
OK                  ("+-" #f)

-> Basic decimal notation
-----------------------------------------------------
OK                  ("1.0" (exact->inexact 1) "1.")
OK                  ("1." 1.0 "1.0" "1.")
OK                  ("1.#" 1.0 1.5 "1.0" "1." "1.5")
OK                  (".1" 0.1 "0.1")
OK                  ("-.1" (- 0.1) "-0.1")
OK                  ("-.0" -0.0 "-0." "-0.0" "0.0" "0." ".0")
OK                  ("-0." -0.0 "-.0" "-0.0" "0.0" "0." ".0")
OK                  ("." #f)
OK                  (".1." #f)
OK                  ("..1" #f)
OK                  ("1.." #f)
OK                  ("#i1.0" 1.0 "1.0" "1.")
OK                  ("#e1.0" 1 "1")
OK                  ("#e-.0" 0 "0")
OK                  ("#e-0." 0 "0")
OK                  ("-#e.0" #f)

-> Decimal notation with padding
-----------------------------------------------------
OK                  ("1#" 10.0 15.0 "10.0" "15.0" "10." "15.")
OK                  ("#e1#" 10 15 "10" "15")
OK                  ("#1" #f)
OK                  ("#" #f)
OK                  ("1#2" #f)
OK                  ("1.#2" #f)
OK                  (".#" #f)
OK                  ("#.#" #f)
OK                  ("#.1" #f)
OK                  ("1#.2" #f)
OK                  ("1#." 10.0 15.0 "10.0" "15.0" "10." "15.")

-> Decimal notation with suffix
-----------------------------------------------------
OK                  ("1e2" 100.0 "100.0" "100.")
OK                  ("1s2" 100.0 "100.0" "100.")
OK                  ("1f2" 100.0 "100.0" "100.")
OK                  ("1d2" 100.0 "100.0" "100.")
OK                  ("1l2" 100.0 "100.0" "100.")
OK                  ("1e2e3" #f)
OK                  ("1e2s3" #f)
OK                  ("1e2.0" #f)

-> Decimal notation with suffix and padding
-----------------------------------------------------
OK                  ("1#e2" 1000.0 1500.0 "1000.0" "1500.0" "1000." "1500.")
OK                  ("1e2#" #f)

-> NaN, Inf
-----------------------------------------------------
OK                  ("+nan.0" the-nan "+NaN.0")
OK                  ("+nan.1" #f)
OK                  ("+nan.01" #f)
OK                  ("+inf.0" pos-inf "+Inf.0")
OK                  ("-inf.0" neg-inf "-Inf.0")
OK                  ("+inf.01" #f)
OK                  ("+inf.1" #f)
OK                  ("-inf.01" #f)
OK                  ("-inf.1" #f)
OK                  ("+nan" #f)
OK                  ("+inf" #f)
OK                  ("-inf" #f)
OK                  ("nan.0" #f)
OK                  ("inf.0" #f)

-> Fractions
-----------------------------------------------------
OK                  ("1/2" (/ 1 2))
OK                  ("10/2" 5 "5")
OK                  ("-1/2" (- (/ 1 2)))
OK                  ("1/-2" #f)
OK                  ("1.0/2" #f)
OK                  ("1/2.0" #f)
PARSE ERROR         ("1/2e2" #f) => 50.0
PARSE ERROR         ("1/2e2" #f) => 50.0
OK                  ("1#/2" 5.0 7.5 "5.0" "5." "7.5")
OK                  ("#e1#/2" 5 (/ 15 2) "5" "15/2")
OK                  ("1/2#" 0.05 "0.05" ".05")
OK                  ("#e1/2#" (/ 1 20) "1/20")
OK                  ("1#/#" #f)
OK                  ("1/" #f)
OK                  ("1/+" #f)
OK                  ("+/1" #f)
OK                  ("/1" #f)
OK                  ("/" #f)

-> Basic complex numbers (rectangular notation)
-----------------------------------------------------
OK                  ("1+2i" (make-rectangular 1 2))
OK                  ("1-2i" (make-rectangular 1 -2))
OK                  ("-1+2i" (make-rectangular -1 2))
OK                  ("-1-2i" (make-rectangular -1 -2))
OK                  ("+i" (make-rectangular 0 1) "+1i" "0+i" "0+1i")
OK                  ("0+i" (make-rectangular 0 1) "+i" "+1i" "0+1i")
OK                  ("0+1i" (make-rectangular 0 1) "+i" "+1i" "0+i")
OK                  ("-i" (make-rectangular 0 -1) "-1i" "0-i" "0-1i")
OK                  ("0-i" (make-rectangular 0 -1) "-i" "-1i" "0-1i")
OK                  ("0-1i" (make-rectangular 0 -1) "-i" "-1i" "0-i")
OK                  ("+2i" (make-rectangular 0 2) "0+2i")
OK                  ("-2i" (make-rectangular 0 -2) "-2i" "0-2i")
OK                  ("1#+1#i" (make-rectangular 10.0 10.0) (make-rectangular 15.0 15.0) "10.0+10.0i" "10.+10.i" "15.0+15.0i" "15.+15.i")
OK                  ("2i" #f)
OK                  ("+-i" #f)
OK                  ("i" #f)
OK                  ("1+2i1" #f)
OK                  ("1+2" #f)
OK                  ("1#+#i" #f)

-> Decimal-notation complex numbers (rectangular notation)
-----------------------------------------------------
OK                  ("1.0+2i" (make-rectangular 1.0 2) "1.0+2.0i" "1.0+2i" "1.+2i" "1.+2.i")
OK                  ("1+2.0i" (make-rectangular 1 2.0) "1.0+2.0i" "1+2.0i" "1.+2.i" "1+2.i")
OK                  ("1#.+1#.i" (make-rectangular 10.0 10.0) (make-rectangular 15.0 15.0) "10.0+10.0i" "10.+10.i" "15.0+15.0i" "15.+15.i")
OK                  ("1e2+1.0i" (make-rectangular 100.0 1.0) "100.0+1.0i" "100.+1.i")
OK                  ("1s2+1.0i" (make-rectangular 100.0 1.0) "100.0+1.0i" "100.+1.i")
OK                  ("1.0+1e2i" (make-rectangular 1.0 100.0) "1.0+100.0i" "1.+100.i")
OK                  ("1.0+1s2i" (make-rectangular 1.0 100.0) "1.0+100.0i" "1.+100.i")
OK                  ("1#e2+1.0i" (make-rectangular 1000.0 1.0) (make-rectangular 1500.0 1.0) "1000.0+1.0i" "1000.+1.i" "1500.0+1.0i" "1500.+1.i")
OK                  ("1.0+1#e2i" (make-rectangular 1.0 1000.0) (make-rectangular 1.0 1500.0) "1.0+1000.0i" "1.+1000.i" "1.0+1500.0i" "1.+1500.i")
OK                  (".i" #f)
OK                  ("+.i" #f)
OK                  (".+i" #f)

-> Fractional complex numbers (rectangular notation)
-----------------------------------------------------
OK                  ("1/2+3/4i" (make-rectangular (/ 1 2) (/ 3 4)))

-> Mixed fractional/decimal notation complex numbers (rectangular notation)
-----------------------------------------------------
OK                  ("1#/2+3/4i" (make-rectangular 5.0 (/ 3 4)) (make-rectangular 7.5 (/ 3 4)) "5.0+0.75i" "5.+.75i" "7.5+0.75i" "5.0+3/4i" "5.+3/4i" "7.5+3/4i")
OK                  ("0.5+3/4i" (make-rectangular 0.5 (/ 3 4)) "0.5+0.75i" ".5+.75i" "0.5+3/4i" ".5+3/4i")
OK                  ("1.5+1#/4i" (make-rectangular 1.5 2.5) (make-rectangular 1.5 3.75) "1.5+2.5i" "1.5+3.75i")
OK                  ("0.5+1/#i" #f)
OK                  ("0.5+1/1#2i" #f)
OK                  ("1/#+0.5i" #f)
OK                  ("1/1#2+0.5i" #f)

-> Complex NaN, Inf (rectangular notation)
-----------------------------------------------------
OK                  ("+nan.0+nan.0i" (make-rectangular the-nan the-nan) "+NaN.0+NaN.0i")
OK                  ("+inf.0+inf.0i" (make-rectangular pos-inf pos-inf) "+Inf.0+Inf.0i")
OK                  ("-inf.0+inf.0i" (make-rectangular neg-inf pos-inf) "-Inf.0+Inf.0i")
OK                  ("-inf.0-inf.0i" (make-rectangular neg-inf neg-inf) "-Inf.0-Inf.0i")
OK                  ("+inf.0-inf.0i" (make-rectangular pos-inf neg-inf) "+Inf.0-Inf.0i")

-> Complex numbers (polar notation)
-----------------------------------------------------
OK                  ("1@2i" #f)
OK                  ("0.5@1/#" #f)
OK                  ("0.5@1/1#2" #f)
OK                  ("1/#@0.5" #f)
OK                  ("1/1#2@x" #f)
OK                  ("1@" #f)
OK                  ("1#@#" #f)
OK                  ("1/@" #f)
OK                  ("@/1" #f)
OK                  ("@1" #f)
OK                  ("1@+" #f)
OK                  ("+@1" #f)
OK                  ("@" #f)

-> Base prefixes
-----------------------------------------------------
OK                  ("#x11" 17 "17")
OK                  ("#d11" 11 "11")
OK                  ("#o11" 9 "9")
OK                  ("#b11" 3 "3")
OK                  ("#da1" #f)
OK                  ("#o8" #f)
OK                  ("#b2" #f)
OK                  ("#o7" 7 "7")
OK                  ("#xa" 10 "10")
OK                  ("#xf" 15 "15")
OK                  ("#xg" #f)
OK                  ("#x-10" -16 "-16")
OK                  ("#d-10" -10 "-10")
OK                  ("#o-10" -8 "-8")
OK                  ("#b-10" -2 "-2")
OK                  ("-#x10" #f)
OK                  ("-#d10" #f)
OK                  ("-#o10" #f)
OK                  ("-#b10" #f)
OK                  ("#x-" #f)
OK                  ("#x" #f)
OK                  ("#d" #f)
OK                  ("#d-" #f)
OK                  ("#d+" #f)
OK                  ("#o" #f)
OK                  ("#o-" #f)
OK                  ("#b" #f)
OK                  ("#b-" #f)
OK                  ("#e" #f)
OK                  ("#e-" #f)
OK                  ("#i" #f)
OK                  ("#i-" #f)

-> Combination of prefixes
-----------------------------------------------------
OK                  ("#x#x11" #f)
OK                  ("#x#b11" #f)
OK                  ("#b#o11" #f)
OK                  ("#e#x10" 16 "16")
OK                  ("#i#x10" 16.0 "16.0" "16.")
OK                  ("#e#e10" #f)
OK                  ("#e#e#x10" #f)
OK                  ("#i#e#x10" #f)
OK                  ("#e#x#e10" #f)
OK                  ("#x#x#e10" #f)
OK                  ("#x#e#x10" #f)

-> Base prefixes with padding
-----------------------------------------------------
OK                  ("#x1#0" #f)
OK                  ("#d1#0" #f)
OK                  ("#o1#0" #f)
OK                  ("#b1#0" #f)
OK                  ("#x1#" 16.0 24.0 "16.0" "24.0" "16." "24.")
OK                  ("#d1#" 10.0 15.0 "10.0" "15.0" "10." "15.")
OK                  ("#o1#" 8.0 12.0 "8.0" "12.0" "8." "12.")
OK                  ("#b1#" 2.0 3.0 "2.0" "3.0" "2." "3.")

-> (Attempted) decimal notation with base prefixes
-----------------------------------------------------
PARSE ERROR         ("#x1.0" #f) => 1.0
OK                  ("#d1.0" 1.0 "1.0" "1.")
PARSE ERROR         ("#o1.0" #f) => 1.0
PARSE ERROR         ("#b1.0" #f) => 1.0
PARSE ERROR         ("#x1.#" #f) => 1.0
OK                  ("#d1.#" 1.0 1.5 "1.0" "1.5" "1.")
PARSE ERROR         ("#o1.#" #f) => 1.0
PARSE ERROR         ("#b1.#" #f) => 1.0
PARSE ERROR         ("#x1." #f) => 1.0
OK                  ("#d1." 1.0 "1.0" "1.")
PARSE ERROR         ("#o1." #f) => 1.0
PARSE ERROR         ("#b1." #f) => 1.0
PARSE ERROR         ("#x.1" #f) => 0.0625
OK                  ("#d.1" 0.1 "0.1" ".1")
PARSE ERROR         ("#o.1" #f) => 0.125
PARSE ERROR         ("#b.1" #f) => 0.5
OK                  ("#x1e2" 482 "482")
OK                  ("#d1e2" 100.0 "100.0" "100.")
PARSE ERROR         ("#o1e2" #f) => 64.0
OK                  ("#b1e2" #f)

-> Fractions with prefixes
-----------------------------------------------------
OK                  ("#x10/2" 8 "8")
OK                  ("#x11/2" (/ 17 2) "17/2")
OK                  ("#d11/2" (/ 11 2) "11/2")
OK                  ("#o11/2" (/ 9 2) "9/2")
OK                  ("#b11/2" #f)
OK                  ("#b11/10" (/ 3 2) "3/2")
OK                  ("#x10/#o10" #f)
OK                  ("10/#o10" #f)
OK                  ("#x1#/2" 8.0 12.0 "8.0" "8." "12.0" "12.")
OK                  ("#d1#/2" 5.0 7.5 "5.0" "5." "7.5")
OK                  ("#o1#/2" 4.0 6.0 "4.0" "4." "6.0" "6.")
OK                  ("#b1#/2" #f)
OK                  ("#b1#/10" 1.0 1.5 "1.0" "1." "1.5")

-> Complex numbers with prefixes
-----------------------------------------------------
OK                  ("#x1#+1#i" (make-rectangular 16.0 16.0) (make-rectangular 24.0 24.0) "16.0+16.0i" "16.+16.i" "24.0+24.0i" "24.+24.i")
PARSE ERROR         ("#x1.0+1.0i" #f) => 1.0+1.0i
OK                  ("#d1.0+1.0i" (make-rectangular 1.0 1.0) "1.0+1.0i" "1.+1.i")
PARSE ERROR         ("#o1.0+1.0i" #f) => 1.0+1.0i
PARSE ERROR         ("#b1.0+1.0i" #f) => 1.0+1.0i
OK                  ("#x10+#o10i" #f)
OK                  ("10+#o10i" #f)
OK                  ("#x1@#x1" #f)
OK                  ("1@#x1" #f)
OK                  ("#x10+11i" (make-rectangular 16 17) "16+17i")
OK                  ("#d10+11i" (make-rectangular 10 11) "10+11i")
OK                  ("#o10+11i" (make-rectangular 8 9) "8+9i")
OK                  ("#b10+11i" (make-rectangular 2 3) "2+3i")
OK                  ("#e1.0+1.0i" (make-rectangular 1 1) "1+1i" "1+i")
OK                  ("#i1.0+1.0i" (make-rectangular 1.0 1.0) "1.0+1.0i" "1.+1.i")

-----> TOTAL ERRORS: 18
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports