Scheme Flashcards

(77 cards)

1
Q

What is the parent language of Scheme?

A

Lisp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Who were the creators of Scheme?

A

Gerald Jay Sussman and Guy L. Steele Jr.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What’s the name of the influential textbook that solidified Scheme’s place in computer science education?

A

Structure and Interpretation of Computer Programs (SICP)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What notation does Scheme use for operators?

A

Prefix notation (Polish notation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of the car function?

A

It returns the first element of a list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of the cdr function?

A

It returns all elements of a list except the first one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the lambda keyword do?

A

Creates an anonymous function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Identify the Scheme construct that allows creating local variables:

A

let

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Identify the Scheme function that allows you to combine multiple expressions to be evaluated in sequence:

A

begin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Identify the Scheme feature that enables defining new functions:

A

define

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Identify the Scheme control structure used for multi-way conditional branching:

A

cond

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Identify the Scheme construct that enables mutation of variables:

A

set!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Identify the Scheme function used to check if an item is a member of a list:

A

member

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Identify the Scheme feature that made it different from other Lisp dialects in its early days:

A

Lexical scoping

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Identify the Scheme construct used to read user input:

A

read

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

True or False. Scheme supports both dynamic and static typing.

A

False - Scheme is dynamically typed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

True or False. In Scheme, parentheses are optional when calling functions.

A

False - parentheses are required

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

True or False. The car and cdr functions are used for list manipulation in Scheme.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

True or False. In Scheme, variables must be declared with an explicit type.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

True or False. Hygienic macros were introduced to make macro expansions safer and more predictable.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

True or False. Scheme uses curly braces {} to define function bodies.

A

False - it uses parentheses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

True or False. Scheme supports first-class functions, meaning functions can be passed as arguments

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
True or False. Scheme is a statically typed language.
False - it's dynamically typed
25
True or False. Racket is a direct implementation of the Scheme language.
False - it's a descendant/dialect of Scheme
26
Assign 10 to variable x
(define x 10)
27
Scheme is classified as:
functional programming language
28
(cons 1 '(2 3))
Construct list → (1 2 3)
29
(car '(a b c))
First element → a
30
(cdr '(a b c))
Rest of list → (b c)
31
Concatenation → "Hello, World!"
(string-append "Hello, " "World!")
32
Single line comment
;
33
34
Prevents evaluation of an expression
' (quote)
35
Boolean true
(#t)
36
Boolean false
(#f)
37
38
True or False. Variables in Scheme are dynamically typed
True
39
Variables declared in ______are global unless inside a let or lambda, making them local.
define
40
Scheme uses___to modify the value of an already defined variable.
set! Example: (define x 10) ; Declare a variable (set! x 20) ; Reassign x to 20
41
Moves to a new line
(newline)
42
Ask user a number and store it in variable num and display it.
(display "Enter a number: ") (define num (read)) (display num)
43
No else if—use ___instead.
cond
44
True or False. Since Scheme is functional, it prefers recursion over loops.
True
45
True or False. Functions in Scheme are first-class citizens, meaning they can be stored in variables, passed as arguments, and returned from other functions.
True
46
Make a function 'square'
(define (square x) (* x x)) (display (square 4))
47
Make a function square using lambda
((lambda (x) (* x x)) 5)
48
A ____allows a function to retain access to variables from its enclosing scope, even after that scope has exited.
closure
49
What is the output: (define (add-ten x) (let ((ten 10)) (+ x ten))) (display (add-ten 5))
15
50
What is the output: (define (counter) (let ((count 0)) (lambda () (set! count (+ count 1)) count))) (define my-counter (counter)) (display (my-counter)) (display (my-counter)) (display (my-counter))
1 2 3
51
Creates a list
list Example: (list 1 2 3)
52
Constructs a pair
cons Example: (cons 1 '(2 3))
53
First element of a list
car (Contents of the Address part of Register number)
54
Rest of the list
cdr (Contents of the Decrement part of Register number)
55
Concatenates lists
append Example: (append '(1 2) '(3 4)) Output: ( 1 2 3 4 )
56
Concatenates strings
string-append Example: (string-append "foo" "bar") Output: “foobar”
57
True or False. Standard Scheme does not have built-in parallel execution
True
58
True or False. Scheme have built-in coroutine support
False. But continuations (call/cc) allow coroutine-like behavior.
59
What does (if #t 1 2) return?
1
60
What does (map (lambda (x) (* x 2)) '(1 2 3)) return?
(2 4 6)
61
What does (cons 0 '(1 2 3)) return?
(0 1 2 3)
62
(display (map (lambda (x) (* x x)) '(1 2 3 4)))
(1 4 9 16)
63
(define (square x) (* x x)) (display (map square '(1 2 3 4)))
(1 4 9 16)
64
(call/cc (lambda (exit) (for-each (lambda (x) (if (> x 5) (exit x))) '(1 2 3 6 7 8))))
6
65
66
(begin (display "Hello, ") (display "World!"))
Hello, World! to make it Hello, World! add (newline)
67
68
69
When was Scheme created?
1975
70
Define a local variable
(let ((x 5)) (+ x 3)) ; This will return 8
71
Scheme use _____ for syntax
S-Expressions
72
The latest standard is
R^7RS Small
73
Converts string to numbers
string->number
74
Converts number to string
number->string
75
Converts string to symbol
string->symbol
76
caddr
third element of the list