CSSE 304 Questions and answers (in progress, last updated 09/02/2016)

These questions were asked on in-class quizzes, or on the Assignment 0 hand-in sheet.

Course Policies How do I know when I am required to bring my computer to class? Almost never!  I'll let you know in advance if you need it.
Scheme What is the difference between let and define? Define binds a value to a variable in the global environment.  Let binds a value to a variable in the local environment in which the body of the let will be executed.  Scheme always looks for values in the local environment (roughly the same as local scope) first, then in the global environment.
Scheme What is an example of a first class data type? In Java:  Every primitive type and object type
In Scheme: Every type (including procedure and continuation)
In Java, the expression a instanceof Method makes no sense.
In Scheme, the expression (procedure? a) makes sense and is legal.
Scheme Is there a simple way to accept user input dynamically in a Scheme program? The main procedures you need to know are read and read-char.  I show them here with no arguments.  They can also be called with an input-port as their argument (an input-port can be created by calling open-input-file). 
A simple example:
(display "enter a Scheme expression: ")
(define x (read))
(display (cons x x))
(newline)
(define junk (read-char)) ;; skip the new-line from the input
(display "enter three characters: ")
(define c (read-char))
(display c)
(newline)
(set! c (read-char))
(display c)
(newline)
(set! c (read-char))
(display c)
(newline)	
And a sample run of this code (user inputs are shown in bold):
enter a Scheme expression: (x y z)
((x y z) x y z)
enter three characters: abc
a
b
c	
Scheme  If a function is created without giving it a name, is it released from memory immediately after execution, or does a garbage collector reclaim it later? Procedures, like all other non-primitive data. live in the heap.  The garbage collector "patrols" the heap looking for unused memory it can recycle.
Scheme Can you trace functions that use lambda?  Like makeAddr: (define makeAddr (lambda (n) (lambda (m) (+ m n)))) Chez Scheme has trace-lambda, trace-let, trace-define.
http://scheme.com/csug8/debug.html#./debug:s0
Scheme

            Can you overwrite lambda?  Like (define (lambda n) (* n n))

Yes.  But you probably would not want to do this!
Scheme

 What is Scheme used for in present day technology?

Scheme and its cousin Common Lisp are frequently use in AI applications.
The example I am most familiar with is Beckman Coulter in Indianapolis, where they use Scheme for the real-time scheduling engine in their robotics software.  They wrote some nifty code to allow Scheme and the .NET CLR to talk to each other. They have also implemented Erlang in Scheme so they can do concurrency cleanly.
Cisco wanted Scheme technology badly enough that they hired Kent Dybvig, purveyor of Chez Scheme, away form Indiana University, and bought the rights to future Chez Scheme development.
Perhaps more relevant now is how Scheme will be used in this course.  Not as an end in itself, but as a platform for exploring various language concepts.
Scheme What use is creating a procedure in a procedure?

Is there a reason to use lambda outside of define?  If not, why is it necessary?

Why would I ever create a procedure and not give it a name?  Procedures maybe useful later on in the program.

What is the advantage of using lambda over how most other languages define functions?

Stay tuned.  You'll see lots of examples in the next few weeks.
Scheme Can you specify what data type you want to use?  I understand that you don’t normally, but there could be cases where you wanted to. Not in Standard scheme.  Several people have written extensions of Scheme that allow or require type specification or inference. For example, http://www.ccs.neu.edu/racket/pubs/popl08-thf.pdf
Style  Which do you prefer:
(define a '(1 2 3)) or
(define b (list 1 2 3))?
It doesn't really matter, but I have a slight preference for the first one.  It is shorter and more readable.
Emacs Does Emacs give you a big advantage, especially considering that it is hard to learn? You'll have to decide this.  I will show some of the nice features during live coding sessions in the classroom, and you can decide whether it is worth climbing  Emacs's steep learning curve in order to get to use its Scheme-specific features.
PL Concepts  Currying? Changing the interface of a multiple-argument function so it takes one argument at a time.    It's sort of  an example of the Adapter pattern (Weiss, Section 4.6.3). 
PL Concepts What is lambda calculus used for outside of programming languages? Lambda calculus (http://en.wikipedia.org/wiki/Lambda_calculus )was invented in the 1930's before there were any programming languages.  It is used as a representation of computation.
The untyped lambda-calculus is Turing Complete (http://en.wikipedia.org/wiki/Turing_complete).  You can find a lot more info (pretty theoretical) in the articles I referenced here.
Here is a reference on an astronomy page:
http://www.absoluteastronomy.com/topics/Lambda_calculus
Miscellaneous What is emacs? Emacs is a "smart" programmable text editor. Many people would say that it is the best text editor.(I have my flame shield up!)  It has been around for about 35 years and is available for almost all operating systems.  Things I like about include the ease of customizing it (via code or keyboard macros) and its excellent interaction with Scheme.  Before Eclipse came along, I also used it for Java development. 
Miscellaneous

 Is it possible to create an executable with Maple?

I doubt it.  Such an executable would have to include the Maple run-time system, and I doubt that the folks at MapleSoft would allow that.
Lexical scoping What is lexical scoping http://whatis.techtarget.com/definition/lexical-scoping-static-scoping
lists  How exactly are internal list structures formed?  They are plain vanilla linked lists, such as you saw in CSSE 220 
     
Not answered yet.
I will answer these as I find time to do so.

 
I feel like Scheme will be difficult to get the hang of.
I am confused by lambda.

Why ((car '(+ -)) 2 3) doesn't work?
When are loads usually performed?
What really is the relationship between Scheme and Lisp?
How are procedures like + and / defined by Scheme, and is that way of defining a procedure directly available in the language?
What is the difference between let and define?
Why do macros not appear until chapter 8?
How did the hand-out (the multi-page one) figure into this assignment?
What is the difference between define and lambda?
What is the difference between eq?, eqv?, and equal? ?
How is the cons procedure used?
Is there a good way to visually describe a Scheme procedure - an equivalent of flowcharting for Scheme?
When running the code of the last question using Dr.Scheme, I received #<promise> - what does this mean?
What is the Scheme equivalent of Object?
I'm confused by how to do tail recursion.
I don't understand the difference between proper and improper lists.
What's the preferred written expression of procedures?
Can you define your own objects or classes in Scheme?
How much has the course changed since previous offerings?
Why does cons create new lists instead of adding to existing ones?
Who thought up this madness, and why weren't they satisfied with C-style coding?
How does shadowing work (when using let or lambda)?
What are lexical scoping and block structure?
What is a form?
Why does (cdr '(a b)) return '(b) instead of b?
Why is '(a . b . c) equal to '(b a c)?
How are car and cdr used?
When are free variables in lambda expressions bound?
Why is (cons '(a b) '(c d)) equal to '((a b) c d)?
What does 'signals an error' mean, with regards to Chez Scheme operation?
Static typing is not the same as strong typing (referring to Python, which was said to lack strong typing).
Has the grading script been improved since last year?
How long does a variable bound with 'let' stay in scope?
Scheme seems to be faster on the dev. side - is it because of the relatively simple code we're currently using, or is the interpreter faster than other bytecode-based VM programming languages like the .NET family and Java?  

What are all the primitive types in Scheme?