Welcome, Guest 
You have to register before you can post on our site.

Online Users 
There are currently 19 online users. » 3 Member(s)  13 Guest(s) Bing, Google, Yandex, dtngo, ianbway



Recursive Variadic Functions 
Posted by: stfuhriman  47 minutes ago  Forum: Assignment 2 / Chapter 2
 No Replies


I spoke with Dr. Lusth about recursive variadic functions and he asked me to share this code as the concepts could be helpful for solving one of the tasks.
(define (f @)
(inspect @)
(cond
((null? @) (println "done"))
(else
(println (car @))
(apply f (cdr @))
)
)
)
Calling f with any number of arguments will print each one on a new line, printing done and then terminating.



task2 
Posted by: jwarburton  1 hour ago  Forum: Assignment 2 / Chapter 2
 Replies (1)


So I was able to get the curry program working for assign1. My question is what is he difference between the assign1 curry problem and the assign2 curry problem?



Task 6 Sorting 
Posted by: sammaryland  Yesterday, 07:34 PM  Forum: Assignment 2 / Chapter 2
 Replies (1)


For enforcing canonical order in Task 6, is it more efficient to sort at each step when two lists are appended, or to sort at the end when the final powerset list is constructed?



Task 2 getting number of arguments 
Posted by: colinmacwilliam  03202019, 09:31 PM  Forum: Assignment 2 / Chapter 2
 Replies (4)


The following code: (length (get 'parameters f)) is not working for me. It results in an error saying that "variable parameters is undefined". I am unsure of what is causing given code snippet not to work for me. I have updated to scam 2.4c and that did not change anything. If i change f into "curry" (the name of the function that is calling this line of code) it successfully gives me the number of arguments my curry function accepts. This is probably super simple but I am stumped as to what is causing this.
Thanks.



Task 6  run time compare 
Posted by: Benjimin Aaron  03202019, 05:19 PM  Forum: Assignment 2 / Chapter 2
 No Replies


What kind of results are you guys seeing for your task6 runtimes?
I am seeing output for:
(println (powerSet '(a b c d e f g h i j )))
in just shy of .6 seconds (~0.58xx)
Increasing the input list by 1 more, I see output for:
(println (powerSet '(a b c d e f g h i j k)))
in just over 1 second. (~1.15xx)
Is anyone getting times that are on an order faster than these?
I suspect I may be losing some time due to my wonky implementation, but what I really want to know is if im off by orders of magnitude here.



Task 4 Clarification 
Posted by: WLoumakis  03202019, 04:05 AM  Forum: Assignment 2 / Chapter 2
 No Replies


1. The spec states:
you may assume the given function, if it contains a let*, has the let* as its body.
Is this to mean that we are not guaranteed that the function passed into let*>lambdas will have a let* as its body? Or is it assumed that if we call let*>lambdas, we will be passing in a list representing a function that has a let* in the body?
2. Also, if we are given something such as the following:
Code: (define (f) (let* ((x 2) (y (+ x 1)) (z 42)) (+ x y z)))
Are we to promote z to the outermost lambda, or does it matter where it goes?
I.e., is this:
Code: (define (f) ((lambda (x z) ((lambda (y) (+ x y z)) (+ x 1))) 2 42))
correct, or is this:
Code: (define (f) ((lambda (x) ((lambda (y z) (+ x y z)) (+ x 1) 42)) 2))
correct, or does it not matter? I'm assuming the first is more correct since z doesn't reference another variable, but I just want to double check.
3. I also assume that since Scam has sequential execution that if y was listed before x in the let* that y would reference an x outside of the scope of the let* rather than within the scope of it. Is this correct?
EDIT: After talking with Dr. Lusth, everything here has been clarified.
1. If we are given a function, we are not guaranteed to have a let* within the body of that function. However, if we are given a function with a let*, it will have at least one variable.
2. Each lambda only has one parameter. That is, for each variable defined with the let*, there will be a corresponding lambda containing solely that parameter.
3. Since Scam has sequential execution, the y would reference an x outside of the scope of the let*.



Task2 Output 
Posted by: jaw653  03202019, 01:27 AM  Forum: Assignment 2 / Chapter 2
 Replies (3)


I noticed that the spec for task2 output reads
Code: ((curry f) 1) is <anonymous(@)>
for the first line.
However, my program outputs
Code: <function anonymous(@)>
I'm assuming this is due to the fact that I updated to scam 2.4c and that this is simply a typo in the spec. Am I correct in this thinking?



Task 1 Assign 2 
Posted by: jwarburton  03192019, 04:09 PM  Forum: Assignment 2 / Chapter 2
 Replies (2)


Under the sample test on the assignment page it has this
$ cat task1.args
(println (range 0 10 5))
(forloop (range 0 10 5) (lambda (x) (inspect x)))
Are the println and the forloop lines what goes in the .args file? Because from my understanding cat shows whats in the file right?



