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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 171
» Latest member: cawilkins
» Forum threads: 180
» Forum posts: 556

Full Statistics

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

Latest Threads
task2
Forum: Assignment 2 / Chapter 2
Last Post: Benjimin Aaron
45 minutes ago
» Replies: 1
» Views: 13
Recursive Variadic Functi...
Forum: Assignment 2 / Chapter 2
Last Post: stfuhriman
47 minutes ago
» Replies: 0
» Views: 5
Task 5 - return value cre...
Forum: Assignment 2 / Chapter 2
Last Post: WLoumakis
Today, 03:16 AM
» Replies: 4
» Views: 89
Task 6 Sorting
Forum: Assignment 2 / Chapter 2
Last Post: lusth
Yesterday, 08:35 PM
» Replies: 1
» Views: 37
Task 2 getting number of ...
Forum: Assignment 2 / Chapter 2
Last Post: lusth
Yesterday, 07:59 PM
» Replies: 4
» Views: 95
task7 inpuits
Forum: Assignment 2 / Chapter 2
Last Post: lusth
Yesterday, 02:51 PM
» Replies: 1
» Views: 38
Notes from class
Forum: Class notes
Last Post: katiez07
Yesterday, 02:34 PM
» Replies: 12
» Views: 1,415
Task2 Output
Forum: Assignment 2 / Chapter 2
Last Post: lusth
Yesterday, 12:50 PM
» Replies: 3
» Views: 84
Task 6 - run time compare
Forum: Assignment 2 / Chapter 2
Last Post: Benjimin Aaron
03-20-2019, 05:19 PM
» Replies: 0
» Views: 46
Task 4 Clarification
Forum: Assignment 2 / Chapter 2
Last Post: WLoumakis
03-20-2019, 04:05 AM
» Replies: 0
» Views: 51

 
  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.

Print this item

  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?

Print this item

  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?

Print this item

  task7 inpuits
Posted by: sthouvenot - Yesterday, 12:30 AM - Forum: Assignment 2 / Chapter 2 - Replies (1)

Are the inputs for task7 in row-major format or column-major format?

Print this item

  Task 2 getting number of arguments
Posted by: colinmacwilliam - 03-20-2019, 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.

Print this item

  Task 6 - run time compare
Posted by: Benjimin Aaron - 03-20-2019, 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.

Print this item

  Task 4 Clarification
Posted by: WLoumakis - 03-20-2019, 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*.

Print this item

  Task2 Output
Posted by: jaw653 - 03-20-2019, 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?

Print this item

  Task 1 Assign 2
Posted by: jwarburton - 03-19-2019, 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))
   (for-loop (range 0 10 5) (lambda (x) (inspect x)))

Are the println and the for-loop lines what goes in the .args file? Because from my understanding cat shows whats in the file right?

Print this item

  Task 1 - Input question
Posted by: ekjohnson4 - 03-19-2019, 02:11 PM - Forum: Assignment 2 / Chapter 2 - Replies (2)

If we were to utilize an input such as '(for-loop (range 0 0 5) (lambda (x) (inspect x)))', would this just return an empty line? Or do we need to handle such a case in another way?

Print this item