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

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 160
» Latest member: zezima
» Forum threads: 439
» Forum posts: 1,391

Full Statistics

Online Users
There are currently 6 online users.
» 1 Member(s) | 5 Guest(s)
dzung

Latest Threads
Will the vertex not be a ...
Forum: Project 3
Last Post: ACCD
7 hours ago
» Replies: 0
» Views: 12
Accessing Test Cases
Forum: Project 2
Last Post: rshowe
Yesterday, 08:03 AM
» Replies: 0
» Views: 13
Minimum Depth Test #2
Forum: Project 2
Last Post: rshowe
Yesterday, 08:01 AM
» Replies: 0
» Views: 15
Method to get last submis...
Forum: Project 2
Last Post: rcfrederick
11-23-2017, 07:52 PM
» Replies: 1
» Views: 26
A lot of new test cases
Forum: Project 3
Last Post: rcfrederick
11-23-2017, 07:50 PM
» Replies: 0
» Views: 26
Test files
Forum: Project 2
Last Post: ianbway
11-23-2017, 04:48 AM
» Replies: 5
» Views: 252
Finishing extremely effic...
Forum: Project 2
Last Post: stvnengineer
11-20-2017, 03:30 PM
» Replies: 4
» Views: 139
Exam Date/Time
Forum: Final Exam
Last Post: ianbway
11-19-2017, 08:00 PM
» Replies: 1
» Views: 57
Some large input test cas...
Forum: Project 3
Last Post: ZachWassynger
11-18-2017, 09:59 PM
» Replies: 3
» Views: 121
Inconsistencies between t...
Forum: Project 3
Last Post: radagast
11-18-2017, 09:22 PM
» Replies: 1
» Views: 66

 
  'var' keyword
Posted by: dzung - 10-08-2017, 08:06 PM - Forum: Project 1 - Replies (3)

Will "var" be exactly in the case defined in the spec?

Print this item

  Task 7 Helpful Webpage
Posted by: davidmccoy - 10-08-2017, 03:43 PM - Forum: Assignment 2 - No Replies

https://chaosatthesky.wordpress.com/2013...s-problem/

I was pretty lost on how the queens algorithm worked, and this page helped me understand it better.

Print this item

  Will 'x' be Assign value twice?
Posted by: ACCD - 10-08-2017, 07:06 AM - Forum: Project 1 - Replies (2)

Such as will the file be like "var x = 3.1 var x = 5.4" ? So I need change 'x' value? 
Or will " var apple = 12.6" appear?

Also will you use ours string.c/h  file or your string.c/h file? 

Because I make  newSTRING function become 

STRING *newSTRING(char *x, double d)
 
If our string file was different, my code may not pass the test.

Print this item

  #6-8 2.3 Missing Parenthesis
Posted by: davidmccoy - 10-08-2017, 03:29 AM - Forum: Miscellany - Replies (1)

Quote:Assuming ab, and c have value 2, 3, and 4, respectively, what is the print value of the expression 
Code:
(car (list 'a 'b 'c)
?
Should be:
Quote:Assuming ab, and c have value 2, 3, and 4, respectively, what is the print value of the expression 
Code:
(car (list 'a 'b 'c))
?
Same for #7 and #8.

Print this item

  Exercise 2.55
Posted by: davidmccoy - 10-08-2017, 03:22 AM - Forum: Exam 2 - Replies (1)

Quote:Eva Lu Ator types to the interpreter the expression

Code:
(car ''abracadabra)

To her surprise, the interpreter prints back quote. Explain.

When I inspect ''abracadabra, I get (quote (quote abracadabra)) is (quote abracadabra), but why is this a list of quote and abracadabra instead of (quote abracadabra) being evaluated to the symbol abracadabra?

Print this item

  Idea/Name Thread
Posted by: davidmccoy - 10-08-2017, 02:36 AM - Forum: The Designer Programming Language - Replies (3)

What are you all thinking about idea/name -wise for this thing? Obviously the most important step, before even creating a grammar, is to get an idea and name it.

Personally, the best I've come up with is Interpreted Dynamically-typed C, or idc. Maybe instead of 

Code:
int number = 5;

I'll do 
Code:
declare number as 5.

I've found attempts at "human-readable" languages to usually be pretty bad, but want to attempt one anyway b/c idc.

Print this item

  #8 2.2 Practice Question
Posted by: davidmccoy - 10-08-2017, 02:13 AM - Forum: Exam 2 - No Replies

Yeah, the binary search tree was pretty easy to draw with cons, but I'm pretty lost on the trinary search tree representation.

Quote:Draw a cons structure in the style of the text that represents a trinary search tree with the elements 3, 1, 2, 1, 5, 1 inserted in that order. A trinary search tree behaves just as a binary search tree except duplicates are inserted as middle children. Use nils to indicate missing children. 


[Image: epKOAzl.png]

Print this item

  #25 2.2 Optimization Practice Question
Posted by: davidmccoy - 10-08-2017, 02:08 AM - Forum: Exam 2 - No Replies

Looking to see if anyone can write something simpler than what I got for #25 (adds items in a list, including sublists).

Code:
(define (list+ items)
   (define (inner-list+ sum remainingItems)
       (if (null? remainingItems)
           sum
           (if (list? (car remainingItems))
               (inner-list+ (+ sum (list+ (car remainingItems))) (cdr remainingItems))
               (inner-list+ (+ sum (car remainingItems)) (cdr remainingItems))
               )
           )
       )
   (inner-list+ 0 items)
   )

I guess you could probably flatten the list first, then just add every element?

Print this item

  #22 2.2 Practice Question
Posted by: davidmccoy - 10-08-2017, 01:52 AM - Forum: Exam 2 - No Replies

Quote:(3 points) Define a function named list? that determines whether a given cons structures is a list at the top level. Do not check if sub-structures are lists. Do not perform any error checking. 

A list merely is a cons structure where the last consed thing is null, right? For example:
Code:
(cons 1 (cons 2 3))
^ not a list

(cons 1 (cons 2 (cons 3 nil)))
^ list


So I'm guessing we can use pair? to check if the thing we're on is a pair or not? If so, I believe we can achieve list? by the following:
Code:
(define (list? item)
    (if (not (pair? item))
        (null? item)
        (list? (cdr item)
        )
    )

Print this item

  #13 2.2 Practice Question
Posted by: davidmccoy - 10-08-2017, 12:39 AM - Forum: Exam 2 - No Replies

EDIT: I partially found the answer to my own question at http://beastie.cs.ua.edu/proglan/accum.html

Quote:13. Suppose I wish to find the product of all the prime numbers from 1 to n? Pick from the components enumeratemapkeepremoveaccumulate, and prime?. Start with n.

I did not see any example of enumerate on its own in the textbook (only enumerate-interval and enumerate-tree).
Can we assume enumerate takes a function to decide a number's inclusion, an incrementer, a starting value, and an ending value?
Code:
(enumerator inclusion-test inc start end)

If so, I would propose the following solution:
Code:
(accumulate * 1
           (enumerate
                   (lambda (x) (if (prime? x) x 1))
                   (lambda (x) (- x 1))
                   n
                   1
                   )
           )

^ accumulate takes a function to grow values, an initial value, and a list of values.

Print this item