your help is appriciated

Statistics: Posted by azoozbmw — Tue Apr 21, 2015 11:48 pm

]]>

]]>

If you wanrt Scheme as in a standard language you need to use #!r5rs or #r6rs

#lang scheme was the same as #!racket, thus not Scheme at all, and it's deprecated. It might suddenly stop working.

When yo press Run in DrRacket IDE, does it stop at the same part? I get this output:

a = balance, p = principle, r = rate,

m = compounding periods, t = time

Compound Interest Formula:

(solve-for-balance p r m t)

(solve-for-principle a r m t)

(solve-for-rate p a m t)

(solve-for-time p a r m)

(solve-for-principle a r m t)

Interest Compounded Continuously:

(solve-for-balance-cont p r t)

(solve-for-principle-cont a r t)

(solve-for-rate-cont p a t)

(solve-for-time-cont p a r)

Which is OK since after this you are defining procedures but you never call any of them enywhere.

It's like buying a really good coffe mug and have it in your kicthen without trying to put any coffe in it or drink from it.

Using *display** in every procedure is not good practice. If you want the result displayed it's better to display the result. eg. *(display (solve-for-balance 10 2 3 8))*

Statistics: Posted by sylwester — Thu Apr 09, 2015 6:52 pm

]]>

#lang scheme

;INTRODUCTION

(display " a = balance, p = principle, r = rate,")

(newline)

(display " m = compounding periods, t = time")

(newline)

(newline)

(display "Compound Interest Formula:")

(newline)

(display "(solve-for-balance p r m t)")

(newline)

(display "(solve-for-principle a r m t)")

(newline)

(display "(solve-for-rate p a m t)")

(newline)

(display "(solve-for-time p a r m)")

(newline)

(display "(solve-for-principle a r m t)")

(newline)

(newline)

(display "Interest Compounded Continuously:")

(newline)

(display "(solve-for-balance-cont p r t)")

(newline)

(display "(solve-for-principle-cont a r t)")

(newline)

(display "(solve-for-rate-cont p a t)")

(newline)

(display "(solve-for-time-cont p a r)")

;COMPOUNDED INTEREST FORMULA

;Solve for Balance

(define (solve-for-balance p r m t)

(define part1

(+ 1 (/ r m)))

(define part2

(expt part1 (* m t)))

(display "$ ")

(display (* part2 p)))

;Solve for Principle

(define (solve-for-principle a r m t)

(define part1

(+ 1 (/ r m)))

(define part2

(expt part1 (* m t)))

(display "$ ")

(/ a part2))

;Solve for Rate

(define (solve-for-rate p a m t)

(define part1

(expt (/ a p) (/ 1 (* m t))))

(display (* 100 (* m (- part1 1))))

(display " %"))

;Solve for Time

(define (solve-for-time p a r m)

(define part1

(log (expt (/ a p) (/ 1 m))))

(define part2

(log (+ 1 (/ r m))))

(display (/ part1 part2))

(display " years"))

;INTEREST FORMULA COMPOUNDED CONTINUOUSLY

;Defining Euler's Number (e)

(define e 2.7182818284590452353602874713527)

;Solve for Balance (Compounded Continuously)

(define (solve-for-balance-cont p r t)

(display "$ ")

(expt (* p e) (* r t)))

;Solve for Principle (Compounded Continuously)

(define (solve-for-principle-cont a r t)

(display "$ ")

(/ a (expt e (* r t))))

;Solve for Rate (Compounded Continuously)

(define (solve-for-rate-cont p a t)

(display (*(/ (log (/ a p)) t) 100))

(display " %"))

;Solve for Time (Compounded Continuously)

(define (solve-for-time-cont p a r)

(display (/ (log (/ a p)) r))

(display " years"))

Statistics: Posted by ec44 — Wed Apr 01, 2015 5:41 pm

]]>

If you need to test your software on a different implementations I recommend Ikarus. (Though both chicken and gambit has good compilers too)

Statistics: Posted by sylwester — Fri Feb 06, 2015 5:07 pm

]]>

http://racket-lang.org/

Many other good Scheme implementations are able to run SICP code, but I think they require a bit more work to get started.

Here's a guide that uses MIT Scheme.

http://hackerretreat.com/why-how-start-sicp/

Statistics: Posted by nuntius — Mon Feb 02, 2015 3:11 pm

]]>

I am a novice going through the book SICP. When doing the exercises, I would like to easily switch between the MIT course materials, some relevant webpages and my code. Preferably, I would like to have a compiler such as Eclipse for Java, i.e. a program that highlights my code and at the same time compiles it (in a split screen). Is there anything comparable in regards of Lisp/Scheme? I am working on a Mac OS X 10.10 (Yosemite).

I have downloaded GNU Emacs from http://emacsformacosx.com/ however this seems to require much knowledge to get into a decent working flow. I hope you can finally get me started, I have struggled now for some time with that... If there is simply no such compiler could anyone tell me how to compile a file using terminal?

Thank you so much for your help.

P.S.: As of now, I have not found a decent tutorial on how to get started with Scheme. Did I miss anything?

Statistics: Posted by trefixxx — Mon Feb 02, 2015 8:11 am

]]>

Is my function gaining anything by calling the recursion last at the expense of function length?

Also is it inefficient to nest function definitions like that? Does the second function get redefined each time the outside function is called or does it get stored once when compiled?

- Code:
`;; Function by user "dsm" on stackoverflow`

(define get-n-items

(lambda (lst num)

(if (> num 0)

(cons (car lst) (get-n-items (cdr lst) (- num 1)))

'()))) ;'

;; Return first n number of items

(define (get-n-items num lst)

(define (loop lst num results)

(if (< num 1)

(reverse results)

(loop (cdr lst) (- num 1) (cons (car lst) results))))

(loop lst num '()))

Statistics: Posted by Pixel_Outlaw — Fri Jan 30, 2015 12:29 am

]]>

]]>

Yes, no sort yet.

I clearly have to learn to think different, more simply.

Statistics: Posted by Datagrace — Mon Jan 05, 2015 10:15 am

]]>