How do you compare two strings and ignore the case in Scheme?
I want to write a function like equalp, which gives #t for (equalp "Xy" "xY"). ...
I want to write a function like equalp, which gives #t for (equalp "Xy" "xY"). ...
Peter Norvig in PAIP says: " in modern lisps...eval is used less often (in fact, in Scheme there is no eval at all)" " if you find yourself using eval, you are probably doing the wrong thing". What are some of the ways to circumvent using eval in scheme? Arent there case where eval is absolutely necessary? ...
Hi, Is there a way I can apply '+ to '( 1 2 3)? edit: what i am trying to say is that the function i get will be a symbol. Is there a way to apply that? Thanks. ...
How do I pass position-independent parameters to scheme functions? ...
How do I accept the following input? (list of 0 or more charcters and ends with 3) or (list of 1 or more characters 4 and 0 or more characters after 4) something like (match ( list 3)) -> #t (match ( list 1 2 3)) -> #t (match (list 1 2 3 4)) -> #t (match (list 1 2 3 4 5)) -> #t (match (list 4)) -> #f EDIT: THIS IS NOT MY HO...
I am facing a couple of problems while writing an auto-memoizer in Scheme. I have a working memoizer function, which creats a hash table and checks if the value is already computed. If it has been computed before then it returns the value else it calls the function. (define (memoizer fun) (let ((a-table (make-hash))) (λ(n) ...
How Do I profile my functions using DrScheme? (require profile) (define (factorial n) (cond ((= n 1) 1) (else (* n (factorial (- n 1)))))) (profile factorial) The above code returns Profiling results ----------------- Total cpu time observed: 0ms (out of 0ms) Number of samples taken: 0 (once every 0ms) =============...
I need to have a newline every time I write to a file in plt scheme. I wonder if there is a special procedure that allows me to do this. ...
I'm learning R5RS Scheme at the moment (from PocketScheme) and I find that I could use a function that is built into some variants of Scheme but not all: Append! In other words - destructively changing a list. I am not so much interested in the actual code as an answer as much as understanding the process by which one could pass a list...
I am confused about the Scheme style for my code. Should I format if forms as: a. if() () () or b. if () () () or c. if () () () Should I format cond clauses as a. cond () () or b. cond () () When do I use a single ; to comment and a double ;;? ...
Hi, I am a C++ programmer, I wrote this code to see if I can think functionally :) Any hints to improve it ? (define (append listOne listTwo) (cond ((null? listOne) listTwo) (else (cons (car listOne) (append (cdr listOne) listTwo))))) (define (merge listOne listTwo) (cond ((null? listOne) listTwo) ((null? listTwo) l...
How do I declare the types of the parameters in order to circumvent type checking? How do I optimize the speed to tell the compiler to run the function as fast as possible like (optimize speed (safety 0))? How do I make an inline function in Scheme? How do I use an unboxed representation of a data object? And finally are any of these...
What are some of the optimization steps that this command does `(optimize speed (safety 0))` Can I handcode some of these techniques in my Lisp/Scheme program? ...
Can I see the translated machine instruction of a scheme function like (disassemble) in LISP? ...
I have an input which is of this form: (((lady-in-water . 1.25) (snake . 1.75) (run . 2.25) (just-my-luck . 1.5)) ((lady-in-water . 0.8235294117647058) (snake . 0.5882352941176471) (just-my-luck . 0.8235294117647058)) ((lady-in-water . 0.8888888888888888) (snake . 1.5555555555555554) (just-my-luck . 1.3333333333333333)))...
I tried doing this: #lang scheme (module duck scheme/base (provide num-eggs quack) (define num-eggs 2) (define (quack n) (unless (zero? n) (printf "quack\n") (quack (sub1 n))))) But I get this error: module: illegal use (not at top-level) in: (module duck scheme/base (provide num-eggs qu...
This is related to http://stackoverflow.com/questions/612761/what-is-call-cc, but I didn't want to hijack this question for my own purposes, and some of its arguments like the analogy to setjmp/longjmp evade me. I think I have a sufficient idea about what a continuation is, I think of it as a snapshot of the current call stack. I don't ...
I need to perform calculations with a symbol. I need to convert the time which is of hh:mm form to the minutes passed. ;; (get-minutes symbol)->number ;; convert the time in hh:mm to minutes ;; (get-minutes 6:19)-> 6* 60 + 19 (define (get-minutes time) (let* ((a-time (string->list (symbol->string time))) (hour (first a-time)...
I'm trying to get my head around how type inference is implemented. In particularly, I don't quite see where/why the heavy lifting of "unification" comes into play. I'll give an example in "pseudo C#" to help clarify: The naive way to do it would be something like this: Suppose you "parse" your program into an expression tree such tha...
I had a pretty simple requirement in my Scheme program to execute more than one statement, in the true condition of a 'if'. . So I write my code, something like this: (if (= 1 1) ((expression1) (expression2)) ; these 2 expressions are to be executed when the condition is true (expression3) ) Obviously, the above doesn't work, ...