constructor - Difference between Ubuntu scheme and XWin Scheme -


i learning 61a ucb using mitscheme.

for first few chapters, have been using windows (first download cygwin, run xwin type emacs & , emacs editor , repl).

this has worked fine have switched ubuntu , using mit scheme. has been working ran problem.

[i using release 9.1 of mit/gnu scheme on ubuntu , stk interperter version 4.0.1 on windows]

i trying write black jack program.

i take input hand of cards '(ad 8s 5h) [for ace diamond, 8 spades, 5 hearts].

to access 'a value, ucb lectures , windows version fine with:

(first (first '(ad 8s 5h))) ===> a

when try on ubuntu mit scheme, error:

the object ad, passed argument safe-car, not pair.

after testing see mit scheme here use first extract first item of list:

(first '(ad 8s 5h)) =====> ad

but not use first selector first letter of single word.

can give me suggestion? keep learning course on ubuntu because makes life easier in terms of saving , opening files example.

thanks,

aj

using first accessing first character in symbol not portable across scheme implementations. in interpreters first or car only work pairs. access first character in symbol create helper procedure:

(define (first-symbol sym)   (string->symbol               ; 4. convert string symbol    (string                      ; 3. create one-character string     (string-ref                 ; 2. first character in string      (symbol->string sym) 0)))) ; 1. convert symbol string 

the above function uses standard procedures, should work fine in rxrs interpreter. use this:

(first-symbol (first '(ad 8s 5h))) => 'a 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -