The cons schema will not accept two number arguments

I saw many examples of flaws taking two numbers as arguments, and I was told to pass two numbers as arguments to the minuses in the laboratory, but whenever I do this, I get the following error:

> (cons 1 2)
cons: second argument must be a list, but received 1 and 2

If I do the following, I get the same error:

> (cons '1 '2)
cons: second argument must be a list, but received 1 and 2

I am very new to Scheme and I do not understand why this is happening.

+4
source share
1 answer

That because of the language of instruction used, you are probably working with a student language with certain limitations. To solve the problem, make sure this line is at the beginning of the file:

#lang racket

" " DrRacket. :

(cons 1 2)
=> '(1 . 2)
+6

Source: https://habr.com/ru/post/1532552/


All Articles