2

In "The Little Typer" book, I am just starting to use DrRacket. From a David Christiansen video, I inputted:

(claim two-plus-two-is-four
  (= Nat (+ 2 2) 4))

which returned an error:

 claim : this function is not defined.

Why?

banbh
  • 1,331
  • 1
  • 13
  • 31

1 Answers1

4

First you need to install pie. In DrRacket you can do this with: File > Package Manager... > Do What I Mean, typing pie in the package source field, and clicking Install.

Alternatively, if you're using the command line you can install it with the command:

raco pkg install pie

Second, if you're using DrRacket you need to make sure "Determine Language from Source" is selected at the bottom-left of the window (on the command-line this is the default).

Third, put #lang pie at the top of your file.

#lang pie

(claim two-plus-two-is-four
  (= Nat (+ 2 2) 4))

This still doesn't work because + isn't built-in; it can be defined in terms of other things that are built-in (this is discussed on pages 72 - 77 of the book).

Alex Knauth
  • 8,133
  • 2
  • 16
  • 31
  • 2
    Alright, it's not just me. I couldn't figure out why `(+ 1 2)` wasn't working. The `+` function is peppered throughout the first few chapters and I'm sure it says somewhere that it isn't defined but I must have missed that. Went a little grayer today trying to compute `(+ 1 2)`. – Ben Kushigian Dec 24 '18 at 17:25