I have a problem in my function where I'm only able to match 1 element in a list, as soon as it hits the first match it results #t. but I want to be able to match all the values in the list. say x1(1111 . 9999), they both should match the list x2(111
I'm working through the Little Schemer and I'm trying to convert all of the answers into Common Lisp. In chapter 8, anonymous functions are discussed, as well as returning anonymous functions. For example: (define insertL-f (lambda (test?) (lambda (n
I'm new to racket and trying to write a function that checks if a list is in strictly ascending order. '( 1 2 3) would return true '(1 1 2) would return false (repeats) '(3 2 4) would return false My code so far is: Image of code (define (ascending?
Is there an easy way to display whole rational numbers for example: (average '(1 2 3 4)) ;returns 2 1/2 I would like it to return 5/2. Thank you.This is DrRacket-specific behavior. It customizes the Racket print handler to print out certain values in
What are the names of the trigonometric functions in Scheme, and what units do they represent angles in?The Scheme standards define six trigonometric functions: sin, cos, tan, asin, acos, and atan. In particular, atan can be called with either 1 or 2
In order to demonstrate the effectiveness of tail recursion, I would like a way to access the depth of the call stack dynamically in Scheme. Is there a way to do this? If not, is there a way to do this in other major functional languages (OCaml, Hask
Suppose I have a procedure called foo, which returns a ::float which is meant to take the following arguments: A procedure taking two ::float arguments. A ::float Another ::float How would I write an export for that function in the module part of the
How do I convert all chars of a port to a string or a list so that I can operate on it as either a list of chars or a string? I was wondering if something similar to (define (port->list port) (list port)) is possible.Racket provides a built-in port->
I am newbie to Scheme programming and trying to define a var in if condition. For example, I have: (if (< x y) (define x y) ) ;(GOAL: if x < y, than x=y..) But I got the error: let: bad syntax (not an identifier and expression for a binding) in:...
I wrote a sum-of-squares function to test if a number n could be written as the sum of two squares. My code is as follows: (define (square x) (* x x)) (define (sum-of-squares n) (define (sum-of-squares-h k) (cond ((= k n) #f) ((= n (+ (square(floor(s
#lang eopl (define (expo base n ) (cond( (or (= base 1) (= n 0) ) 1) (else ( (* base (expo(base (- n 1))) ) ) ))) -> (enter! "expo.rkt") "expo.rkt"> (expo (2 1) ) ; application: not a procedure; ; expected a procedure that can be
Continuation describes what happens next with some value, right? Isn't that just a function that takes a value and does some computation? (+ (* 2 3) 5) the continuation of (* 2 3) is (+ _ 5) (define k (lambda (v) (+ v 5))) What is the point of using
I am implementing R7RS-small Scheme and I have encountered the following problem with the implementation of equal?: (as should be obvious) equal? tests value equality, and it furthermore is able to test the equality of cyclic data structures without
I am trying to solve a puzzle the crawls a binary tree in order to find if a specific value exists as a node. I am having an issue with evaluating a pair that looks like '(1 '()). I think when I evaluate (= 4 '()) it returns true which is incorrect o
I use DrRacket. I have problem with this code: (define (qweqwe n) ( (cond [(< n 10) #t] [(>= (lastnum n) (pochtilastnum n)) (qweqwe (quotient n 10))] [else #f] ) ) ) (define ( RTY file1 file2 ) (define out (open-output-file file2 #:mode 'text #:exis
Can anyone tell me what I need to do here? (define (count-values abst v) (cond [(empty? abst) 0] [else (+ (cond [(equal? v (bae-fn abst)) 1] (else 0)) (count-values .... v) (count-values .... v ))])) I basically need a function that counts the amount
So I know that in Scheme define is for dynamic scoping and let for static scoping, yet the following thing confuses me: If I have (let ((x 0)) (define f (lambda () x)) (display (f)) (let ((x 1)) (display (f)) ) ) It will display 00. So far so good. H
Input1: (decompose '(* 1 2 3 4)) Output1: '(* 1 (* 2 (* 3 4))) Input2 (decompose '(+ 1 2 3 (* 5 6 7))) Output2 '(+ 1 (+ 2 (+ 3 (* 5 (* 6 7))))) Does anyone have ideas about this?Same way as you would evaluate it, but instead of outputting the result,
I have been working on a call to accumulate which goes as follows: (define (accumulate op initial sequence) (if (null? sequence) initial (op (car sequence) (accumulate op initial (cdr sequence))))) However when I try to square something by slecting i
Functions in scheme/racket. Working on a few functions using a binary search tree. I have already defined helper functions to be: ;; returns value of node (define (value node) (if (null? node) '() (car node))) ;; returns left subtree of node (define
I am trying to write a function that can check whether or not some input is a quotation for a syntax checker. I have the following code: (define is-quote-expression? (lambda (v) (equal? (car v) 'quote) (is-quotation? (cdr v))))) (define is-quotation?
I came across the following post on the boost mailing lists (emphasis mine): hello all, does anybody know of an existing spirit/lisp implimentation, and is there any interest in developing such a project in open source? None yet, AFAIK. I'll be writi
I'm new to programming and have had a hard time understanding recursion. There's a problem I've been working on but can't figure out. I really just don't understand how they are solvable. "Define a procedure plus that takes two non-negative integers
I've heard that most lisps support saving image of running program into file. Does guile support this?I think that interoperating with other languages is pretty integral to what Guile is, and so there is a lot of state in an interpreter image that is
I have a couple of books on Scheme, and some of them mention named let and letrec, but none will actually give a convincing example of each (I mean, when and why would I use one instead of the other). Are there examples of situations where letrec/nam
To begin, not only are there two main dialects of the language (Common Lisp and Scheme), but each of the dialects has many individual implementations. For example, Chicken Scheme, Bigloo, etc... each with slight differences. From a modern point of vi
How do you run Scheme programs from the terminal in linux(ubuntu)? Also how to accept arguments from the command-line in a Scheme program? Edit: Im using the DrScheme implementation.The DrScheme scheme implementation, and the name you use to execute
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 eve
Why might the C# language designers not have included support for something like this (ported from Structure and Interpretation of Computer Programs, second ed., p. 30): /// <summary>Return the square root of x.</summary> double sqrt(double x)
Question: ((lambda (x y) (x y)) (lambda (x) (* x x)) (* 3 3)) This was #1 on the midterm, I put "81 9" he thought I forgot to cross one out lawl, so I cross out 81, and he goes aww. Anyways, I dont understand why it's 81. I understand why (lambd