I want to write a program to find the roots of the quadratic equation in Scheme. I used LET for certain bindings.
(define roots-with-let
(λ (a b c)
(let ((4ac (* 4 a c))
(2a (* 2 a))
(discriminant (sqrt ( - (* b b) (4ac)))))
(cons ( / ( + (- b) discriminant) 2a)
( / ( - (- b) discriminant) 2a)...
Looks like R5RS language in DrScheme does not come with hashtable library..
when I run (make-hash-table) it throws an error...
Pretty Big has support for hashtable but does not support mutable pairs..
so I am stuck making one of them work for me ..
How do I add support for hashtable in R5RS?
thanks
...
Berkeley's "CS 61A Lecture 8: UI Recursion and Iteration III" says that
null? checks if the list is empty and empty? checks if the list is empty or the word is empty? The lecturer also goes on to say (null? empty) will return false. But DrScheme doesnt mind at all.
What is the difference between null? and empty? in Scheme?
...
Hello everybody,
I need to make a Server-Client software in bigloo and i need some help to make that.
I am using the latest version of bigloo, but i browsed in internet and there is only an example using an old version.
There they use macros like (socket-dup s) and (thread-await! (make-connect-signal s2)), where s is the server socket ...
When I make a list in Scheme, what does the cdr of the last pair point to? Is it an 'empty word' or an 'empty list'? DrScheme doesnt mind (cons 'a empty) nor (cons 'a '()). Finally what is the difference between the empty word and the empty list?
...
I really want to learn Scheme macros. I glanced over the content of "On Lisp" and a lot of the chapters have been devoted to Lisp macros. However I do not know common lisp. Can I use it to learn Scheme Macros?
...
The ipython python shell has a wonderful feature, whereby you can type:
foo??
and see the text of function foo.
Does scheme (in particular, MIT scheme), have anything like this?
I want to be able to say
(define (foo x) (* x x))
and later view (or even operate on) the list (* x x).
Is there a way to do this?
...
PLT Scheme's documentation says:
The rationale for providing print
is that display and write both
have relatively standard output
conventions, and this standardization
restricts the ways that an environment
can change the behavior of these
procedures. No output conventions
should be assumed for print, so that
envir...
I want to access a n-dimensional vector but somehow (empty? '()) keeps returning false.
;; access n dimensional vectors
;; (access-nd vector a-list-of-numbers) -> element
;; (access-nd (vector (vector 'x 'y) 'a 'b)) 0 1 ) -> x
(define (access-nd avector . alist)
(cond
((and (not(empty? alist)) (vector? avector))
(vector-re...
Hi,
I want to save coordinates of points (X,Y) in a list. Also I want to sort the list by X or Y value every time I add points in that list.
How can I do that?
Thanks in advance.
...
I've written a small Scheme interpreter in C#, and realised that the way I had implemented it, it was very easy to add support for proper continuations.
So I added them... but want to "prove" that they way that I've added them is correct.
My Scheme interpreter however has no support for "mutating" state - everything is immutable.
So i...
Hi,
How can I implement loop in plt-scheme like in java-
for(int i=0;i<10;){
for(int j=0;j<3;){
System.out.println(""+j);
j++;
}
System.out.println(""+i);
i++;
}
Thanks in advance.
...
Hi,
How to go through a list or fetch element from a list in scheme?
How can I name each element (like we do for variables in java) in a list?
Thanks in advance.
I want to compare every point in a list to another point. So, as we do in java or python-
for(int i;i<list.size();i++){
if (list[i]> k){
//do something
}
...
I wanted to make a lazy list in Scheme. This is what I have so far.
;; Constructor for Pairs
(define (cons-stream a b)
(cons a (λ() b)))
;; Selectors
(define (car-stream a-stream)
(car a-stream))
(define (cdr-stream a-stream)
((cdr a-stream)))
;; Lazy List using the pairs
(define (lazy-list from)
(cons-stream from (lazy-list ...
I'm running ypsilon scheme using Emacs 23's scheme-mode. When I enter an expression in the interpreter, it adds an extra newline (see below). I've never seen this happen for any other interpreter. I know ypsilon isn't doing it, because it looks fine in shell-mode a shell (though shell-mode exhibits the same incorrect behavior). What func...
Scheme uses a single namespace for all variables, regardless of whether they are bound to functions or other types of values. Common Lisp separates the two, such that the identifier "hello" may refer to a function in one context, and a string in another.
(Note 1: This question needs an example of the above; feel free to edit it and add ...
(/ 4 3) returns 4/3 as an answer. What is the simplest way to get 1.3...?
...
What is the time complexity of this nifty function 'assoc'?
...
How do I declare that a symbol will always stand for a particular value and cannot be changed throughout the execution of the program?
...
Right now I have
(define (push x a-list)
(set! a-list (cons a-list x)))
(define (pop a-list)
(let ((result (first a-list)))
(set! a-list (rest a-list))
result))
But I get this result:
Welcome to DrScheme, version 4.2 [3m].
Language: Module; memory limit: 256 megabytes.
> (define my-list (list 1 2 3))
> (push 4 my-list)
...