All Questions
11 questions
1
vote
1
answer
59
views
Is an iterative process that returns a list with size that increases by iteration any different from an one that returns a scalar?
This actually comes from me initially misreading the text of Exercise 1.12.
The request is indeed to
Write a procedure that computes elements of Pascal's triangle by means of a recursive process.
I ...
1
vote
1
answer
92
views
How to write a racket function with using tail recursion with couple conditionals
I'm having a problem understanding how to set up a racket function that has a couple conditionals for tail recursion. Normally with one conditional, I would set up the helper function and assign acc ...
3
votes
2
answers
562
views
How to implement append procedure using tail recursion in Scheme/Racket? [duplicate]
For a long time I'm trying to implement the append procedure in Racket using tail recursion(iterative).
The best solution I did so far is this:
(define (my-reverse lst)
(define (iter lst reversed)
...
2
votes
2
answers
145
views
Sum of Multiples in Scheme
so I am very new to Scheme and functional programming as a whole.
I am trying to write a program that finds the sum of all the multiples of 3 or 5 below 1000.
This is my attempt so far :
(define (...
4
votes
2
answers
288
views
Accessing call stack depth in Scheme
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 ...
4
votes
2
answers
365
views
Is there a more efficient way to write this recursive process?
I was asked to write a procedure that computes elements of Pascal's triangle by means of a recursive process. I may create a procedure that returns a single row in the triangle or a number within a ...
-1
votes
2
answers
654
views
why am I getting "application not a procedure"?
I am trying to write a procedure that computes f by means of an iteratve process. The function f is defined by the rule that
f(n) = n, if n < 4 and
f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) + 4f(...
7
votes
3
answers
304
views
2 questions at the end of a functional programming course
Here seems to be the two biggest things I can take from the How to Design Programs (simplified Racket) course I just finished, straight from the lecture notes of the course:
1) Tail call optimization,...
1
vote
3
answers
2k
views
scheme, list of functions as parameter
I'm trying to solve this problem. I was wondering if someone would help get started on it or give me some hints.
function called apply-all that, when given a list of functions and a number, will ...
6
votes
2
answers
866
views
Converting a function with two recursive calls in scheme to make it tail-recursive
Before I start: YES, this is a homework from college. Before I get told that I'm lazy and evil: this part of the homework was to convert two functions we already had, this one is the 6th.
(define (...
3
votes
1
answer
2k
views
Scheme: changing recursion to tail recursion
I'm unsure of how to turn count-forwards into a tail-recursive program. It takes a non-negative number, n, and returns the list of integers from 0 to n (including n).
Edit: Okay, I finally got this ...