All Questions
19 questions
1
vote
2
answers
145
views
Scheme - function to count occurrences of atom in argument
I'm new to scheme and trying to learn functions. I want to create a function where I can count all occurrences of the atom "a" in an argument. This is what I have written so far. I'm not ...
1
vote
2
answers
1k
views
Solving a functional programming problem using dr.racket
I am trying to implement a function called funPower, which takes a function f, an integer n and returns the function f^n. For example ((funPower sqrt 2) 16) should return 2, which is (sqrt (sqrt 16)).
...
2
votes
1
answer
53
views
Understanding a construction (para . contents) and continuing education
I've just started the Scheme Lisp learning and needed some illumination. I've hit a snippet at a site https://www.gnu.org/software/guile/manual/html_node/Types-and-the-Web.html that I haven't caught (...
2
votes
1
answer
59
views
Why is the parameter for my procedure getting a 'not a function' error?
I am going through the book Structure and Interpretation of Computer Programming, which uses Scheme, and I just got through a portion on recursion. I wrote a program for exercise 1.11:
A function f ...
0
votes
1
answer
179
views
Why is this error in my Scheme Cube-Root program showing up?
So I'm working my way through SICP, and one of the problems (1.8) is to implement a cube-root procedure analogous to the square-root procedure using the Newton-Raphson method. I wrote the program and ...
1
vote
1
answer
326
views
How are functions defined in Scheme?
According to my assignment, some of the values defined below in Scheme-notation are functions. I need to determine the value if it is not a function. Otherwise, I have to determine what the function ...
1
vote
2
answers
319
views
Scheme (DrRacket) lambda expression
I do not understand the following program code. Can anyone explain it to me?
(define myFunction
(lambda (f x y z)
(f x y z)))
How can I simplify it?
1
vote
3
answers
261
views
Local: Calling functions from "outside" and from "inside"?
Can I call a function that is inside a local from the "outside"? Lets say we have the function A. It calls a fuction that is inside a local. Function A is not in that local. Is this possible?
Or is a ...
1
vote
1
answer
176
views
What are functions with "memory"?
I'm trying to understand what functions with "memory" are. An example would be this:
;; add : number -> (number -> number)
;; to create a function that adds x to its input
(define (add x)
(...
0
votes
2
answers
665
views
"Adding" two functions together in Scheme
I am going through a practice exam for my programming languages course. One of the problems states:
Define a function named function+ that “adds” two functions together and returns this composition. ...
0
votes
3
answers
148
views
I am trying to sum each parameter with a value, what is wrong with my code?
I am basically new to Scheme, and this is my second attempt to solve a certain problem.
So what I am trying to do basically is sum each parameter we pass into the function, with an appropriate value
...
-2
votes
2
answers
60
views
What this functions in Scheme language do?
I'm a newbie and I didn't understand very well the language. Could anyone please explain to me what this functions do?
First function:
(define (x l)
(cond
((null? l) 0)
((list? (...
0
votes
1
answer
218
views
Scheme - Passing too much arguments into a function doesn't cause error?
Given the following code :
(define (g x y) (* x y))
(define (f x y z)
(define (h x y)(g (+ x y) x z))h)
Notice that I pass 3 arguments into g ,where g accepts only 2 .
However ,no error ...
3
votes
4
answers
7k
views
Scheme - have a function return a function
I want to use this code in the following way:
if I enter:
((function1 5) 2)
where function1 executes its procedure based off the 5, and returns a function2 that executes something based on the 2. Is ...
1
vote
1
answer
297
views
Using abstract list functions to iterate over a list of functions in Scheme
How can I write a function max-list-function that consumes a list of functions, then produces a function f such that for every x, (f x) produces the maximum value of all the functions g in the list of ...