문제

I'm reading a old book

Simply Scheme: Introducing Computer Science

you can find it here .

In the fifth section it introduces the "selectors", operators like the following:

(first 'abcd) ;-> A
(butfirst 'abcd) ;-> BCD

and so on..

Does it exist something similar in R6RS? (since this operators are not defined).

도움이 되었습니까?

해결책

As per my comment, this will probably be quite difficult.

Another aspect is that Simply Scheme sees symbols as 'strings'.

With that info you could write the following:

(define (first s)
  (string->symbol (string (car (string->list (symbol->string s))))))

(define (butfirst s)
  (string->symbol (apply string (cdr (string->list (symbol->string s))))))

Also note that symbols are case-sensitive in R6RS, so the result will be the same case case passed to the procedure.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top