Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Missing Scheme Main Library Procedures
#1
In fiddling with scam, I have encountered a number of procedures which are in the scheme documentation, but which are neither in scam's main library documentation, nor are recognized by the scam interpreter as existing. 

Some examples: "truncate", "round", "floor", and "ceiling". It seems as though a portion of the library is missing.

My question is whether or not this is intended. "list-ref" is also not recognized by my interpreter, but scam provides "getElement", which provides the same functionality. Are the above procedures omitted from scam? If so, is there a replacement provided for them? If they are not omitted, is mine a faulty scam installation, or is there an external library missing?
Reply
#2
Scam is not Scheme. My intent is that the code in Chapters 1, 2, and 3 run under Scam (with a few exceptions, one being variadic functions).

There is a file in your distribution, called mit.scm, that makes Scam look more like the subset of Scheme in Chaps 1, 2, and 3. You can include it:

(include "mit.scm")

I can add those missing functions (if they are mentioned in the text book).
Reply
#3
(09-03-2017, 12:52 AM)lusth Wrote: Scam is not Scheme. My intent is that the code in Chapters 1, 2, and 3 run under Scam (with a few exceptions, one being variadic functions).

There is a file in your distribution, called mit.scm, that makes Scam look more like the subset of Scheme in Chaps 1, 2, and 3. You can include it:

(include "mit.scm")

I can add those missing functions (if they are mentioned in the text book).

"Round" is specified on page 201 of the text book (Chapter 2.5), and its functionality is required for task 3 of programming assignment 1 (as the color values are rounded).
Reply
#4
(09-05-2017, 07:29 PM)frostymelonade Wrote: "Round" is specified on page 201 of the text book (Chapter 2.5), and its functionality is required for task 3 of programming assignment 1 (as the color values are rounded).

http://beastie.cs.ua.edu/mybb/showthread...147#pid147

Code:
(integer (+ n 0.5))
UA ACM Vice President
ACM has bi-weekly meetings Tuesdays at 5:15pm
We're UA's best organization for CS majors (website)
Join us on Slack for all kinds of discussion channels (including one for CS403)
Reply
#5
I'll add it to the main library. You can edit main.lib in your scam folder and add the function:

(define (round x) (integer (+ x 0.5)))
Reply
#6
While adequate for this programming assignment, using (integer (+ 0.5 x)) for rounding does not yield expected results if x is negative.
Reply
#7
(09-06-2017, 03:03 PM)frostymelonade Wrote: While adequate for this programming assignment, using (integer (+ 0.5 x)) for rounding does not yield expected results if x is negative.

Good point.


Code:
(define (round x)
    (if (< x 0) (integer (- 0.5 x)) (integer (+ 0.5 x))
    )
UA ACM Vice President
ACM has bi-weekly meetings Tuesdays at 5:15pm
We're UA's best organization for CS majors (website)
Join us on Slack for all kinds of discussion channels (including one for CS403)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)