tailrecursion-modulo-cons Questions

1

For example, this is not a tail call : map _ [] = [] map f (x : xs) = f x : map f xs the recursive callis guarded by the (:) data constructor, so it won't build up a huge stack like an equivalen...

5

Solved

I'm working through "Learn Prolog now" online book for fun. I'm trying to write a predicate that goes through each member of a list and adds one to it, using accumulators. I have already done it e...

2

Solved

In the chapter about function in the Oz tutorial, it says that: similar to lazy functional languages Oz allows certain forms of tail-recursion optimizations that are not found in certain stri...

5

i've seen several examples of implementing append an element to a list, but all are not using tail recursion. how to implement such a function in a functional style? (define (append-list lst elem)...

2

Solved

This is an algorithm to append together two lists: Domains list= integer* Predicates nondeterm append(list, list, list) Clauses append([], List, List) :- !. append([H|L1], List2, [H|L3]) :- appe...
Digastric asked 16/5, 2012 at 13:50

2

Solved

I'm very new to Scala, so forgive my ignorance! I'm trying to iterate of pairs of integers that are bounded by a maximum. For example, if the maximum is 5, then the iteration should return: (0, 0)...
Headman asked 9/5, 2012 at 23:15

5

I've searched high and low and can't seem to find a lot of material related to run-time complexities, recursion, and java. I'm currently learning run-time complexities and Big-O notation in my Al...

3

Solved

As in this code: import Data.Char groupsOf _ [] = [] groupsOf n xs = take n xs : groupsOf n ( tail xs ) problem_8 x = maximum . map product . groupsOf 5 $ x main = do t <- readFile "p8.log" ...
Isolationist asked 25/11, 2011 at 23:46

2

Solved

I'm working on Okasaki's Purely Functional Data Structures and trying to build F# implementations of things. I'm also going through the exercises listed in the book (some are pretty challenging). W...
1

© 2022 - 2024 — McMap. All rights reserved.