Skip to main content

All Questions

0 votes
1 answer
113 views

Ramda recursive curried function throws Maximum call stack size exceeded

I try to understand ramda a bit better and why in the following example mapTreeNode2 does not work exactly like mapTreeNode. In a new project my state is represented in a huge tree and I want to make ...
Christine's user avatar
  • 3,064
-3 votes
3 answers
670 views

find in deep nested array (tree) recursivley

I want to find a value in the following nested array without using loops: let children = [ { name: 'grand 1', children: [ { name: 'parent 1.1', children: [ { ...
Thore's user avatar
  • 33
0 votes
2 answers
48 views

Improve debugging output of a recursive function

I have the following recursive function to count the number of ways change can be returned given various coin denominations: function makeChange(amount, coins) { // Note: using Floats here ...
David542's user avatar
  • 111k
0 votes
3 answers
152 views

Why Higher Order Function Is Only Called Once

I'm struggling to understand why memoize in this example appears to only be called once. Looking at the code, I would expect "memo prints once" to print with each layer of recursion. However,...
WriterState's user avatar
0 votes
2 answers
80 views

Make Recursive Function Functional in Javascript

I am implementing a recursive encryption for Javascript objects but the solution I came up with is non-functional. This has caused some weird errors as it manipulates the object directly. Is there any ...
Paolo Tormon's user avatar
2 votes
2 answers
248 views

Left associative binary tree fold

With the normal right associative tree fold I can define pre-/in-/post-order just by rearranging the concatenation in the supplied function f: const treeFoldr = f => acc => function go(t) { ...
user avatar
2 votes
4 answers
262 views

Higher-order function with recursion in Javascript

newbie here... I'm trying to grasp the concept of functional programming in Javascript, but I got stuck. I'm trying to apply a function to another function with recursion (higher-order function). Let'...
NCL82409's user avatar
1 vote
3 answers
110 views

Confusion with state of parameter in recursion with javascript

Gif for the debugger in console So, when running this, i'm a bit confused how fac parameter is maintaing the state. what i understand by factorial(4) is 4 * (4-1) // 4 * 3 = 12 12 * (3-1) // 12 * 2 = ...
Ittisafur's user avatar
1 vote
2 answers
94 views

Recursion not returning right result

I am working on a problem where I would like to transform the following object structure: [ { "label": "testType", "categories": [ { ...
gameFrenzy07's user avatar
2 votes
3 answers
482 views

How to edit tree structure?

The tree structure looks like this - const init = [ { name: 'A', children: [ { name: 'A1', children: [] }, { ...
shishir's user avatar
  • 41
0 votes
4 answers
346 views

Functional way to parse nested dictionary into array of each level's elements

I'd like to solve a problem in a functional style in javascript. My dict looks like this: [{ "title": "A", "isFinal": false, "children": [{ ...
DavidS1992's user avatar
0 votes
1 answer
237 views

Recursively Traverse Object till last leaf node JavaScript

I am working with Lucene Syntax (a AND b, c OR d) as a search query and I need to translate this search query. In order to translate the Lucene Syntax to a JavaScript object, I use Lucene Parser npm ...
Ankit Tanna's user avatar
  • 1,821
1 vote
1 answer
821 views

Tail call optimization (TCO) not working in Safari

According to ES6 compatibility table, Safari has tail call optimization feature. Tried it and it fails just like any other browser 😭. Am I missing something? function factorial(n, r = 1n) { ...
kornieff's user avatar
  • 2,557
1 vote
2 answers
1k views

Pascal's Triangle with Recursion in JS - Explanation Asked

I have checked the other topics. It looks like these issues mainly concerns C++ and Python devs but wanted to ask to have a better understanding about recursion. A Pascal Triangle is a triangle that ...
afyonkes's user avatar
  • 155
1 vote
3 answers
1k views

Counting up and down in recursive manner in JS

I am currenty working on functional programming techniques. There are topics about this issue [ especially there is one about java ] but not about JS. I want to create a recursive function that can ...
afyonkes's user avatar
  • 155

15 30 50 per page
1
2 3 4 5