Question

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).

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top