Section 1

Preview this deck

Ports are abstractions used to represent sources of ___ and output

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (105)

Section 1

(50 cards)

Ports are abstractions used to represent sources of ___ and output

Front

Input

Back

A ___ is an ordered sequence of characters

Front

String

Back

What are the two classes of data types?

Front

Simple and compound

Back

The vector-___ function can be used to retrieve a value from a vector by index, the vector-___ function can be used to reassign a value in a vector by index

Front

ref, set!

Back

The ____ function can be used to get the current output port

Front

current-output-port

Back

The ___ function can be used to execute a series of expresions

Front

begin

Back

The first sub-form in a list-form is called the ___

Front

Head

Back

How do you specify a tab character? A space?

Front

#\tab, #\space

Back

The lambda form implicitly acts as a begin form. t/f

Front

t

Back

___ are expressions which can be evaluated

Front

Forms

Back

If a top-level function f modifies a top level variable x, and f is called within a fluid-let which defines a variable x, which instance of x will be modified, the local or the global?

Front

The local

Back

What are the 4 types of numbers?

Front

Integer, rational, real and complex

Back

The ___ form is a special case of the cond form where the second sub-form evaluates to a value and the heads of the remaining sub-forms contain list forms which indicate a value which the value of the second sub-form must equal for the remaining sub-sub-forms in that sub-form to be executed, the last of which is returned

Front

case

Back

The ___ function indicates that the interpreter shouldn't evaluate the proceeding expression, and instead treat it as a value

Front

quote

Back

___ scope implies that a symbol is bound to the variable defined in the most immediate parent scope with respect to the body where the symbol is referenced (not necessarily the body which INVOKES the body where the symbol is referenced)

Front

Lexical

Back

All expressions are self-evaluating. t/f

Front

f

Back

The ___ form can be used to temporarily shadow a global variable in bodies OUTSIDE of the immediate body in the form

Front

fluid-let

Back

The ___ function is used to define a variable

Front

define

Back

What's the general comparison function? The comparison function for numbers?

Front

eqv, =

Back

What does the second sub-form in a lambda expression specify? What are the 3 alternate ways that it can be specified?

Front

The local variables used to refer to the function arguments. A list-form, a symbol, or a dotted pair

Back

s-expressions are values which are either part of the set of ___ data types or ___ data types

Front

Simple, compound

Back

The ___ form contains n subforms which are evaluated sequentially, where the head of each is expected to return a truthy value which indicates wherther the remaining sub-sub-forms in that sub-form will be evaluated, and the result of the last returned, in which case the remaining sub-forms are unevaluated. The last sub-form is evaluated if none of the preceeding sub-forms are

Front

cond

Back

What's the function to display something in stdout? What's the optional parameter used for, and what's it's value when omitted?

Front

display, specifying the output port, stdout (or the current output port?)

Back

How can you specify a literal list value?

Front

Using a quote and parentheses: ex. '(1 2 3)

Back

The car function returns the ___ item in a pair, the cdr function returns the ___ item

Front

First, second

Back

The ___ function can be used to convert a string to a list of characters

Front

string->list

Back

If a top-level variable x is defined, and a function accepts a parameter named x, if the value of x is updated in the function using a set! form, which instance of x will be modified, the local or the global? What if the function didn't accept a parameter named x?

Front

The local. The global

Back

The ___ form evaluates it's sub-forms and returns #f if any evaluate to #f without executing the remaining sub-forms, else it returns the value of the last sub-form

Front

and

Back

A named (i.e. define-d) function cannot call itself. t/f

Front

f

Back

The boolean? function returns #t if it's argument is a ___ type, and false otherwise

Front

Boolean

Back

What's the function to load an external script in the interpreter?

Front

load

Back

A ___ type is specified using a character prefixed by '#\'

Front

Character

Back

What does it mean if a variable is 'shadowed' within a given body?

Front

It means that any (more) global definitions of that same variable, specified in parent scopes, are overiden in the context of the given boy

Back

A ___ is an ordered couple of values with arbitrary types

Front

Pair

Back

A ___ or a ___ are ordered sequences of values with arbitrary types

Front

Vector, list

Back

What are the 4 simple data types?

Front

Booleans, numbers, characters and symbols

Back

The ___ let form can be used to define local variables for a given body of forms

Front

let

Back

When the second sub-form in a lambda form is specified as a symbol, what is the effect on how the are arguments are locally defined? What if a dotted pair is used?

Front

The symbol refers to a list of the arguments. The first n symbols before the dot refer to the first n arguments, the symbol after the dot refers to a list of the remaining arguments

Back

When the interpreter evaluates a ___-form, if the head refers to a function, it returns the result of applying that function with the remaining items in the list as arguments

Front

list

Back

The second subforms of the when and unless forms are implicit begin forms. t/f

Front

t

Back

What's the function to write a newline to stdout?

Front

newline

Back

The ___ form is used to define a (nameless) function

Front

lambda

Back

The ___ function accepts 2 sub-forms, where the first is a symbol referencing a function, and the second is a list containing arguments to be applied to that function

Front

apply

Back

The cons function is used to construct a ___

Front

Pair

Back

___ forms are interpreted differently than list-forms

Front

Special

Back

What's the difference between let and let*?

Front

let* allows you to define local variables which refer to previously defined variables in the same let form, as if you had defined a nested let within the let which defined the first variable

Back

The ___ function takes 2 numerical argments and returns the first argument expoentiated by the second

Front

expt

Back

The ___ form evaluates it's first sub-form and if the evaluation returns a true (non-false) value, it evaluates and returns the result from the second sub-form, otherwise it does the same for the third sub-form. Which form can be used to only do the first half of this behavior? The second?

Front

if. when. unless

Back

A ___ data type can be specified using #(1 2 3) (for example)

Front

Vector

Back

The ___ form evaluates it's sub-forms and returns the first non-false value without executing the remaining forms, else it returns #f

Front

Back

Section 2

(50 cards)

A ___ is defined as a function which transforms a set of given sub-forms into a different set of sub-forms, to be subsequently executed

Front

macro

Back

The ___ function is used to get the standard (console) input port. The ___ gets the equivalent output port

Front

current-input-port. current-output-port

Back

The ___ function invokes the given method on a given class instance

Front

send

Back

An ___ continuation is one which prematurely returns a result without executing the remainder of the surrounding expression wherein the continuation is invoked

Front

Abortive

Back

What are the 2 write operations that can be performed on input ports - what are the respective functions? How do you write a newline to an output port?

Front

Write a character or an s-expression; write-char, write/display. The newline function (takes an optional port argument)

Back

When defining classes as instances (i.e. instance vectors), when new instances are created how are the class precedence lists created from the direct superclasses? The list of slots?

Front

The class precedence lists from each superclass are combined into a single list, with duplicates removed. Similarly, the list of slots from each of the superclasses are combined into a single list, with duplicates removed

Back

What is the function to close an input port? An output port?

Front

close-input-port. close-output-port

Back

What function does the assv function use to compare the given key to the keys in the given association list? What's the approach if you wanted to use a different function?

Front

eqv?. Define a 'table' struct which contains fields for an association list and a comparison function

Back

The ___ function is used to delete a file

Front

delete-file

Back

A named let is syntactic sugar for what?

Front

A letrec form which defines a local function with the same name as the let, it's parameters as those defined as the local variables of the let, and it's body as that of the let

Back

What function is used to define a macro?

Front

define-macro

Back

What does a backquote/backtick/quasiquote enable you to do?

Front

Specify a template for a quoted expression, within which you can insert externally-defined values

Back

How do you specify a default value for a field when creating a struct?

Front

Use a 2-item list form when specifying the field in the defstruct invocation, ex. (defstruct struct-name field1 (field2 'default-value))

Back

What function is defined by defstruct which creates a struct instance (assuming that the struct is named 'struct-name')? What methods are would be created to get and modify a field named 'field-name', respectively?

Front

make-struct-name. struct-name.field-name, set!struct-name.field-name

Back

All ports should be closed after use. t/f. If not, what are the exceptions?

Front

All except string ports

Back

How can a loop be defined using a let form? What ensures that this approach is efficient, in terms of mitigating the overhead of function invocation?

Front

Using a let, with a locally defined recursive function which is invoked in the body. Tail-call elimination

Back

What parameters does the defstruct-generated make-function accept?

Front

Quoted symbols, each indicating a field name and followed by a value for the given field. ex. (make-struct-name 'field1 'value 'field2 456)

Back

The ___ function creates an input port from a string. The ___, an output port. The ___ function is used to get the string from the output port

Front

open-input-string, open-output-string, get-output-string

Back

When a subclass is created, how are the slots of the subclass and the superclass combined? How are the methods combined?

Front

The slots are merged; duplicate slots are eleminated, the slots from the subclass being preserved and those of the superclass being discarded (?). Duplicate methods are also eliminated, where the last duplicate is preserved, and the rest are eliminated (?)

Back

The ___ function returns the first element of a vector which represents a class instance, returning #t by default, if the given argument is not a vector

Front

class-of

Back

In a quasiquoted list, how do you insert an s-expression? How do you insert an s-expression with it's surrounding parentheses removed?

Front

`(,s-expression). `(,@s-expression)

Back

The ___ form is specifically supported to locally define mutually recursive functions in it's body

Front

letrec

Back

The ___ macro can be used to define a set of methods which can be used to create and interact with an instance of a set of related, named data fields

Front

defstruct

Back

What function can be used to automatically close and input file after use? An output file? What are their parameters?

Front

call-with-input-file. call-with-output-file. A string containing the file name, and a unary lambda which accepts the port as an argument

Back

The ___ function is used to see if a file exists

Front

file-exists?

Back

What's an association list?

Front

A list form where each entry is a dotted pair, the first item in each pair being interpreted as a key, and the second item as a value

Back

Continuations can be used to create ___ - functions that have stored state which affects their return values during successive invocations

Front

Generators

Back

What does the assv function do?

Front

Given an association list and a key, it returns the dotted pair which contains that key

Back

The ___ function gets the value of a given slot from from a given class instance. The ___ function sets the value

Front

slot-value, set!slot-value

Back

___ is a struct which contains members for a list of 'slots' (data members), a list of method names, and a vector of lambdas, pointing to the methods associated with the aforementioned method names

Front

standard-class

Back

How do you create an input port for a file, by name? An output port?

Front

open-input-file, open-output-file

Back

___ are functions which save their state (using continuations (exclusively?)) before calling (one) another, to be resumed by (one) another at a later point in time

Front

Coroutines

Back

A class instance is a ___, where the first element is a reference to the class, and the remaining are twosomes where the first element of each twosome is a slot name, and the second is a value for that slot

Front

vector

Back

The ___ function applies a function to each item in a given list without returning the result

Front

Back

What's the difference between the write and display functions?

Front

write prints it's output in a machine-readable format (ex. strings are written with surrounding quotes, characters are prefixed with #\), display doesn't

Back

How is tail-call elimination possible? What conditions are necessary?

Front

The recursive function must be invoked as the last sub-form in the function body. Since this is the case, the overall result of the function will be equal to the result returned by the last recursive invocation of the function - the interpreter doesn't need to return to the contexts of the previous calls; it won't affect the result

Back

The ___ function (abbreviated 'call/cc') takes a lambda which accepts a single argument - a continuation - which permits the enclosing expression to be invoked like a function inside the lambda, accepting an argument that will be substituted for the call/cc expression within the surrounding expression

Front

call-with-current-continuation

Back

What are the 3 read operations that can be performed on input ports - what are the respective functions?

Front

Read the next character, the next line, or the next s-expression; read-char, read-line, read

Back

The ___ function executes a given string as an operating system command, returns #t if the exit status of the command was 0, #f if it was 1, and prints the output of the command to stdout

Front

system

Back

When a continuation is stored in a variable, it cannot be invoked more than once. t/f

Front

f

Back

The map function can apply a function to more than one list. t/f

Front

t

Back

Since classes can be considered instances too, you can represent a class as a vector. With support for multiple inheritance, the what would the 5 (?) values of the vector reference? What are the values set to for the standard class?

Front

The first would be a reference to the class of the instance, which would need to set to the standard class for the standard class. The second would be a list of the slots in the vector (i.e. (list 'slots 'superclass-precedance (?) 'method-names (?) 'methods (?)). The third would initially be an empty list. The fourth would be '(make-instance). The fifth would be a list containing a reference to the make-instance procedure

Back

The load function loads a relative path with respect to where the file is located, not where the interpreter is started. t/f. If not, which function does?

Front

f. The load-relative function

Back

The ___ function gets the value of a given environment variable

Front

getenv

Back

The ___ function returns a list of the results returned from a given function as applied to each of the respective items in a given series of lists

Front

map

Back

When defining classes as instances (i.e. instance vectors), how can a new class instance be created?

Front

By using the send method to call the make-instance method on the standard class

Back

Which sub-form in a named let indicates the name? Do the other sub-forms differ from those in an ordinary let?

Front

Second. No

Back

What are the (standard?) functions for a table struct? What does each do?

Front

table-get (get's the value (not the dotted pair) associated with a given key, using the equivalence function in the struct), table-put! (updates the value associated with a given key (or adds a new dotted pair containing the key and value if the key isn't in the table?)), table-for-each (applies a lambda to each dotted pair within a for-each form, where the lambda accepts the first and second items of each dotted pair as two separate parameters

Back

The ___ function reads and executes s-expressions sequentially from a given source file

Front

load

Back

Class methods are not part of the class, they're part of the class instance. t/f

Front

f

Back

Section 3

(5 cards)

The amb macro must choose a value which causes the whole program to converge, not just an option in it's list which converges - that is, if a choice by amb produces a failure later in the program (whereby later in the program amb is called with no arguments), amb must 'backtrack' and choose another value. t/f

Front

t

Back

What invocation of amb is guaranteed to generate an error which triggers a backward traversal along amb's decision tree to the most recent invocation

Front

Calling amb with not arguments: (amb)

Back

An ___ can be implemented as a function which evaluates an expression which returns a boolean, and calls amb with no arguments if the result is false

Front

assertion

Back

Procession within the amb 'decision tree' which is enumerates when evaluating options for convergence is done breadth-first. t/f

Front

f - it's depth-first

Back

The ___ macro is used to make an ambiguous choice between a set of optional return values, and return it

Front

amb

Back