TOC of the series
The very first thing we need to do in order to change from ISL to Racket is to select the appropriate language via the DrRacket's menu 'Language:Choose Language'.
We will choose
#lang racket/base. You can also select
#lang racket. The first option loads the base of Racket, and everything else has to be required on demand. The second option loads the core and many other libraries.
racket/baserequirement of our previous version is, of course, no longer needed.
Before trying to run the code, please comment out all tests. We will look into them in the next post.
If you run the code now you will get a syntax error. This is expected. ISL+ is not Racket.
A first quick fix is to require
racket/list, which provides functions like
first used in our prior implementation.
Another simple fix has to do with
symbol=? is provided by
racket/bool. You could require that module. Or, as we are going to do, use the more generic
equal?. In general, though, it is better to use a specific function like
explode is another function only available in teaching languages. You have two options here: implementing your own version of
explode or refactoring the function that uses
isbn-string->numbers. We choose the second approach, that iterates now on
Char's instead of on
A more serious modification has to do with local definitions. This is an *SL construct. Most of the time you should use a simple
define instead, but you may need
let forms in other special cases.
The resulting transformation looks as follows:
Next article in the series: Racket:
rackunit, test submodules