ghci)
| Haskell Function | Scheme Analog |
|---|---|
| == | eq? |
| <, >, <=, >= | <, >, <=, >= |
| mod | modulo |
| div | quotient |
| not | not |
| !! | list-ref |
| filter | filter |
| all | andmap |
| any | ormap |
| take | (returns a prefix of a list) |
| takeWhile | (returns the prefix of a list satisfying a predicate) |
Any function whose name begins with a symbolic character is an infix
operator. Other binary functions can be used as infix operators by
enclosing in backquotes (e.g., x `mod` y). Also, infix
operators can be used as ordinary functions by enclosing in
parentheses (e.g., (!!) [1, 2, 3] 2).
When you load a file, the prompt will read "*Main", not CS173.
The error messages are different (and a bit harder to read in GHCI), but are reporting the same problem.
GHCI prints out some types a bit differently. The type for len,
for example, looks like (Num a1) => [a] -> a1. This has
the same content as the type shown in the text once you substitute Num
for a1 (read the => as implication).
GHCI doesn't produce the missing pattern warning mentioned on page 66 of the text (the tB function). Instead, GHCI produces a run-time error if you should need the missing pattern.
In the interpreter, GHCI reports a name clash with "lookup". Rename lookup to Main.lookup (or use a different name for lookup) to avoid the error.
eqString is not built-in in GHCI. You can define it
as
eqString s1 s2 = (length s1 == length s2) && all id (zipWith (==) s1 s2)
expressions entered at the command line must be on a single line
use let to enter a definition on the command line
(as in let double n = n * 2)
Haskell is case-sensitive
filenames must start with capital letters
type names must start with capital letters
identifiers for values should be in lower case
Show converts values to a string for printing. If
you get an error about Show, you are trying to print something without
a standard string representation (like a function)
You can write lambda-style functions using \ for lambda. For
example, (\x -> x * 2) is the anonymous function that
multiplies a number by 2
constructors for types and data are in different namespaces, so you can reuse names across them