Thank you guys !

Statistics: Posted by Domus123 — Tue Mar 08, 2016 6:57 pm

]]>

- Code:
`(define (my-list . args)`

args)

(my-list 1 2 3 4) ; ==> (1 2 3 4)

Notice that you have posted this in the Scheme section so this is a Scheme implementation. Scheme uses the word procedure instead of function.

Statistics: Posted by sylwester — Sat May 09, 2015 1:01 pm

]]>

Anyways, to the problem, I've already described my problem on stack overflow in as much detail as I could put there. Whenever I write the "exponent" procedure in the same file as the command that calls it up, it works, but runs into the above error when it gets loaded up from an external file. Any help is appreciated.

Arigatou Gozaimasu.

^ _ ^

Statistics: Posted by theblacksquid — Wed May 06, 2015 12:07 am

]]>

- Code:
`((expr1)`

(expr2)

(expr3))

the first member of a list (expr1) is evaluated and used as an function, thus for a block of code there is an function begin:

- Code:
`(begin (expr1)`

(expr2)

(expr3))

Solution for your little problem is:

- Code:
`(define print-list`

(lambda (l)

(if (null? l)

(display "done\n")

(begin

(display (car l))

(newline)

(print-list (cdr l))))))

Statistics: Posted by Goheeca — Tue May 05, 2015 2:18 pm

]]>

I'm attempting to write a function that prints each entry of a list on its own line using by re-cursing on the tail. Here's what I have:

- Code:
`(define print-list`

(lambda (l)

(if (null? l)

(display "done\n")

( (display (car l)) (newline) (print-list (cdr l)) ))))

(print-list '(1 2 3 4 5) )

Here's how I'm running it and what I get:

- Code:
`john@home:~/code/lisp$ tinyscheme helloworld.scm`

1

2

3

4

5

done

Error: (helloworld.scm : 8) illegal function

Errors encountered reading helloworld.scm

john@home:~/code/lisp$

The thing runs as I expected, but then shows me the error message and exits. What have I done wrong?

Thanks very much in advance!

Statistics: Posted by flagrant2 — Sun May 03, 2015 11:51 pm

]]>

The executable you create will not have a read-eval-print-loop, so be sure to have an expression that starts your program running in the definitions window before creating the executable.

Therefore, you have to write your own REPL or use the built-in one.

Statistics: Posted by Goheeca — Thu Apr 30, 2015 11:39 am

]]>

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

]]>