Error when loading/running
Newbie here. I'm trying to run a scheme program from gsi and getting an error I don't understand: C:\gambit\gambitv4.6.2\v4.6.2\bin>type timecalc.sch (define hrs1) (define hrs2) (display "Hrs 1: ") (set! hrs1 (read)) (display "\nHrs 2: ") (set! hrs2 (read)) (print "\n\n" (+ hrs1 hrs2) " hours --> $" (* (+ hrs1 hrs2) 22))' C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi -:d0 timecalc.sch C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi timecalc.sch *** ERROR IN "timecalc.sch"@7.1 -- Datum expected C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi Gambit v4.6.2
(load "timecalc.sch") *** ERROR IN "timecalc.sch"@7.1 -- Datum expected 1>
Any tips? TIA, Steve
Afficher les réponses par date
You have a single quote floating out there with nothing after it. You probably should also define hrs1 and hrs2 to something, and not rely on `set!' to return a value. On Oct 31, 2011 11:45 AM, "Steve Graham" <jsgrahamus@yahoo.com> wrote:
Newbie here. I'm trying to run a scheme program from gsi and getting an error I don't understand:
C:\gambit\gambitv4.6.2\v4.6.2\bin>type timecalc.sch (define hrs1) (define hrs2) (display "Hrs 1: ") (set! hrs1 (read)) (display "\nHrs 2: ") (set! hrs2 (read))
(print "\n\n" (+ hrs1 hrs2) " hours --> $" (* (+ hrs1 hrs2) 22))'
C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi -:d0 timecalc.sch
C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi timecalc.sch *** ERROR IN "timecalc.sch"@7.1 -- Datum expected
C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi Gambit v4.6.2
(load "timecalc.sch") *** ERROR IN "timecalc.sch"@7.1 -- Datum expected 1>
Any tips?
TIA, Steve
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Thanks, all. I noticed that I "print" will not handle decimals properly. I've googled for formatted output for Gambit and Scheme and haven't found any info on this that applies to Gambit. Have also looked in the latest version of The Scheme Programming Language and it also does not deal with formatted decimals, although it does mention printf, which Gambit seems to lack. Any comments on how to print formatted decimals? Thanks again, Steve ________________________________ From: Jeff Read <bitwize@gmail.com> To: Steve Graham <jsgrahamus@yahoo.com>; gambit List <gambit-list@iro.umontreal.ca> Sent: Monday, October 31, 2011 9:51 AM Subject: Re: [gambit-list] Error when loading/running You have a single quote floating out there with nothing after it. You probably should also define hrs1 and hrs2 to something, and not rely on `set!' to return a value. On Oct 31, 2011 11:45 AM, "Steve Graham" <jsgrahamus@yahoo.com> wrote: Newbie here. I'm trying to run a scheme program from gsi and getting an error I don't understand:
C:\gambit\gambitv4.6.2\v4.6.2\bin>type timecalc.sch (define hrs1) (define hrs2) (display "Hrs 1: ") (set! hrs1 (read)) (display "\nHrs 2: ") (set! hrs2 (read))
(print "\n\n" (+ hrs1 hrs2) " hours --> $" (* (+ hrs1 hrs2) 22))'
C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi -:d0 timecalc.sch
C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi timecalc.sch *** ERROR IN "timecalc.sch"@7.1 -- Datum expected
C:\gambit\gambitv4.6.2\v4.6.2\bin>gsi Gambit v4.6.2
(load "timecalc.sch") *** ERROR IN "timecalc.sch"@7.1 -- Datum expected 1>
Any tips?
TIA, Steve _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On 2011-10-31, at 12:27 PM, Steve Graham wrote:
Thanks, all.
I noticed that I "print" will not handle decimals properly. I've googled for formatted output for Gambit and Scheme and haven't found any info on this that applies to Gambit. Have also looked in the latest version of The Scheme Programming Language and it also does not deal with formatted decimals, although it does mention printf, which Gambit seems to lack.
Any comments on how to print formatted decimals?
Thanks again, Steve
I've used this function in the past. Marc (define (fmt num #!optional (d 6) (w 0)) ;; Formats a number to a string, where d is the number of decimals ;; and w is the total width. (let ((n (floor (inexact->exact (round (* (abs num) (expt 10 d))))))) (let ((i (quotient n (expt 10 d))) (f (modulo n (expt 10 d)))) (let ((si (string-append (if (< num 0) "-" "") (if (and (= i 0) (> d 0)) "" (number->string i 10)))) (sf (number->string (+ f (expt 10 d)) 10))) (if (> d 0) (string-set! sf 0 #\.) (set! sf "")) (let ((lsi (string-length si)) (lsf (string-length sf))) (let ((blanks (- w (+ lsi lsf)))) (string-append (make-string (max blanks 0) #\space) si sf))))))) (print (fmt 3.1415926 3)) ;; prints 3.142
Works great, Marc. Thanks. Guess I misunderstood "The Scheme Programming Language": printf is a form he develops in the book and it's not part of the standard. Steve ________________________________ From: Marc Feeley <feeley@iro.umontreal.ca> To: Steve Graham <jsgrahamus@yahoo.com> Cc: gambit List <gambit-list@iro.umontreal.ca> Sent: Monday, October 31, 2011 11:19 AM Subject: Re: [gambit-list] Error when loading/running On 2011-10-31, at 12:27 PM, Steve Graham wrote:
Thanks, all.
I noticed that I "print" will not handle decimals properly. I've googled for formatted output for Gambit and Scheme and haven't found any info on this that applies to Gambit. Have also looked in the latest version of The Scheme Programming Language and it also does not deal with formatted decimals, although it does mention printf, which Gambit seems to lack.
Any comments on how to print formatted decimals?
Thanks again, Steve
I've used this function in the past. Marc (define (fmt num #!optional (d 6) (w 0)) ;; Formats a number to a string, where d is the number of decimals ;; and w is the total width. (let ((n (floor (inexact->exact (round (* (abs num) (expt 10 d))))))) (let ((i (quotient n (expt 10 d))) (f (modulo n (expt 10 d)))) (let ((si (string-append (if (< num 0) "-" "") (if (and (= i 0) (> d 0)) "" (number->string i 10)))) (sf (number->string (+ f (expt 10 d)) 10))) (if (> d 0) (string-set! sf 0 #\.) (set! sf "")) (let ((lsi (string-length si)) (lsf (string-length sf))) (let ((blanks (- w (+ lsi lsf)))) (string-append (make-string (max blanks 0) #\space) si sf))))))) (print (fmt 3.1415926 3)) ;; prints 3.142
participants (3)
-
Jeff Read -
Marc Feeley -
Steve Graham