• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Scheme master please help

jliao20

Junior Member
Im writing two scheme , but i run into some problems.. im using Dr.Schme.. and im limited only to use use the following pre-defined Scheme procedures : define, lambda, cond (including the else notation), if, cons, car, cdr, null?, =, equal?, list?, odd?, and, or, not, +, -, *, /, <, <=, >, >=

(calc-running-sums L)
The calc-running-sums function takes a simple list L of numbers and returns a list containing the running sums from L. The nth element in the returned list is the sum of the first n elements in L.
Examples:
(calc-running-sums '(1)) => (list 1)
(calc-running-sums '(2 2 2 2 2)) => (list 2 4 6 8 10)
(calc-running-sums '(2 5 8)) => (list 2 7 15)

(filter-items F L)
The filter-items function takes a function F (which takes one argument and returns a boolean result) and a list L. The job of filter-items is to call F on each of the elements of L, returning a list of all the elements in L for which F returned true, while leaving out all the elements in L for which F returned false. This is a pretty powerful function that can solve a wide variety of problems. (In general, we say that higher-order functions are those that take other functions as arguments. Why they're called "higher-order," and why they're so powerful, is because you can send an arbitrary function to configure them, so that they can solve problems that you haven't even conceived of yet.)
The examples below make use of a few predefined Scheme functions, to show how versatile filter-items will be when you're done with it. Feel free to use these functions in your tests for filter-items, even though they're not on the list of functions you can use in your solutions:

  • positive?, which returns true if its argument is a positive number and false if not
  • odd?, which returns true if its argument is an odd number and false if not
  • string-length, which takes a string as an argument and returns the number of characters in the string
Examples:
(filter-items positive? '(1 -3 2 -4 3 -5 4 -6)) => (list 1 2 3 4) (filter-items odd? '(1 2 3 4 5 6)) => (list 1 3 5) (filter-items is-increasing? '((1 4) (4 3 2) (5 6)) => (list (list 1 4) (list 5 6)) (filter-items (lambda (s) (<= (string-length s) 4)) '("Alex" "is" "happy" "today")) => (list "Alex" "is") im totally lost and i tried so many different combo and it still doesn't work .. any help would be appricated ;]
 
Those sound like some fun problems, what have you attempted so far? Nobody here is going to flat out give you any answers, most of us have been in your shoes doing these exact problems at one point. If you give us code that you've already written in an attempt to solve the problem we'll be more likely to help you out and point you towards the right resources to figure out how to solve the problem.
 
You know how dumb it is to copy problems verbatim from your homework and post them online? Especially when your post basically asks for the answers?

You should probably contact this guy before I do: thornton@ics.uci.edu
 
You know how dumb it is to copy problems verbatim from your homework and post them online? Especially when your post basically asks for the answers?

You should probably contact this guy before I do: thornton@ics.uci.edu

😀 I lol'd.

Back on topic... man learning Scheme was awesome. It was my first (and last, so far) functional language. There's so much crazy shit you can do w/functional languages. Our final project involved implementing (not from scratch) a meta-circular evaluator. Programming in C just doesn't have this:

yo-dawg-lisp.jpg
 
😀 I lol'd.

Back on topic... man learning Scheme was awesome. It was my first (and last, so far) functional language. There's so much crazy shit you can do w/functional languages. Our final project involved implementing (not from scratch) a meta-circular evaluator. Programming in C just doesn't have this:

yes I remember my final project was also writing a meta eval. kinda brings back memory. But all that paren matching is tough though.

I think OP should work on this on your own or at least have an attempt written out. The best way to understand something is try to use it.
 
yes I remember my final project was also writing a meta eval. kinda brings back memory. But all that paren matching is tough though.

Please don't tell me you wrote code in Notepad. Any reasonably decent programmer's editor will do the matching for you.
 
Back
Top