47,437 questions
-2
votes
0
answers
36
views
Euler problem 1 Common Lisp recursive solution not working [closed]
I just started playing around with Common Lisp and tried the first euler problem which states to sum all the divisors of 3 OR 5 under some given parameter x. I would like to use a recursive solution ...
3
votes
2
answers
156
views
Recursive C function for creating number permutations
I do understand I have mistakes in this code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int diziyi_yazdır(int dizi[], int dizi_uzunluğu)
{
for (int i ...
2
votes
1
answer
115
views
How to write an accumulative recursive function in J without looping
At the risk of asking a question with an obvious solution: if I have a function in J that takes two arguments and returns two arguments and I want to accumulate the answer's second argument and to use ...
1
vote
2
answers
151
views
How exactly does recursion work in x86 assembly?
My question is focused specifically on assembly (intel). In C for example, recursion can be done with a simple return command but in assembly I feel like there's a lot more things going on, especially ...
1
vote
2
answers
146
views
Given the string input, how can we traverse the binary tree recursively
Let's say our binary tree (bt) looks like this:
Node* root = new Node();
root->left = new Node("B");
root->right = new Node();
root->right->right = new Node("A");...
2
votes
1
answer
105
views
Sequential compilation times of a jax-jitted recursive function
I have a recursively defined function my_func that is jitted using jax.jit from the jax library. It is defined below:
# Imports
import jax
import jax.numpy as jnp
from functools import partial
import ...
0
votes
1
answer
34
views
Display tree depth using VLT recursion
I'm trying to render a tree structure using VLT, by indenting the rendering depending on the level it's on.
I tried to use a recursive macro which passes on the $indentLevel variable (see code below). ...
0
votes
0
answers
157
views
Stop Condition for Self-Referential Marcos
Background
I am on an ARM Cortex-A72. To access bit fields of my core's system registers I use a macro code generation mechanism. For the sake of simplicity, I replaced void operator=(const uint64_t v)...
14
votes
1
answer
361
views
Why does Deducing-This lambda require `this` to be a reference or capturing variables by reference?
Why does this code output garbage on GCC like there is a UB?
auto data = std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto output = [data](this auto self, size_t i) {
if (i >= 10) {
...
0
votes
1
answer
104
views
Recursive function to create and populate dynamic-depth nested dictionary [closed]
I am attempting to build and populate a data structure consisting of multiple, but variable count, nested dictionaries in C#. I am currently using a recursive function to do so.
The data stored in the ...
0
votes
1
answer
122
views
Python lambda returns 0 [closed]
Is there a simple way to return 0 with a lambda function using and and or operators?
For example, consider this function to sum elements in an array:
sum = lambda tab: tab == [] and 0 or tab[0] + sum(...
4
votes
2
answers
81
views
Graph recursive walk in Scheme
I have an undirected graph which nodes are numbered from 0 to 5. Adjacencies are given with a vector of lists #((1 2) (0 3) (0) (1) (5) (4))), thus node 0 is connected to nodes 1 and 2, node 1 is ...
3
votes
1
answer
104
views
How do I make a Prolog rule that only reads the lists inside lists?
I am somewhat new to Prolog, having only practised for a few months so far. I am stumped on the following problem and nothing I googled seemed to help.
I wrote the following code into a Prolog ...
0
votes
0
answers
150
views
How to implement a generalized N-Sum algorithm for variable k (user input) in Java? [duplicate]
I’ve already solved 2-Sum and 3-Sum problems:
2 sum uses a HashMap to check if target - nums[i] exists in HashMap.
3 Sum sorts array and then uses 2 pointers.
Yesterday, during Flipkart GRID Coding ...
0
votes
0
answers
66
views
Control recursive function evaluation depth in eval
As an exercise, to get a good idea of what Z3 can and can't do, I was trying to solve a "coraline" puzzle. This is a rectangular grid, where each square is a graph node of degree two: each ...
4
votes
2
answers
185
views
C with inline assembly - recursive function that calls within the asm statement
I am fairly new to assembly.
After compiling, when I run the code below, I get a segmentation fault.
I am trying inline assembly with recursion. I am compiling this code with cxxdroid.
int ...
0
votes
0
answers
54
views
Retrieve all pages iteratively using completablefuture
DAO has methods that return completableFuture. To avoid fetching huge result at once, I want to fetch it in pages from DB.
The recursive solution stops when result size < pageSize
However, to avoid ...
0
votes
1
answer
43
views
Antlr4 simple direct right recursive not work
exp: 'a' exp | 'a';
If the input is just an 'a', I get a error. Doesn't antlr4 support direct right recursive?
I have noticed that antlr4 supports direct left and right recursive. Why this simple ...
0
votes
1
answer
43
views
allocatable recursive one directional list, sort by selection. fortran
its a task for my uni, and i thought i would be able to make it, but its the 5th day in a raw.
i have to make in recursive, and i have to make it sort by selection, so
I am sorting surnames by ...
4
votes
1
answer
151
views
Why does a recursive lambda with deduced return type not work?
int main() {
auto fn = []<typename T>(this auto&& self, T n) {
if (n > 0) {
self(n - 1);
}
};
fn(3);
}
Compiled with clang-20 -std=c++23 but ...
-1
votes
1
answer
73
views
What form of recursion is occurring in the "insert "and "list_all" methods of this code?
I am struggling to understand the recursion going on in the insert, _insert_recursive and _inroder_traversal methods. For context, I know recursion and the concept is not strange to me, I struggle to ...
0
votes
1
answer
48
views
finding of parent of an html node in javascript using recursion? [duplicate]
Basically I need a less stupid way to do this:
var x = getElementById('not-important');
x.parentElement.parentElement.parentElement.parentElement....parentElement.style.display = 'none';
In my case ...
0
votes
1
answer
44
views
Jekyll recursive include causing "Nesting too deep" error when rendering nested comments
I'm working on a Jekyll site and encountering a "Nesting too deep" error when trying to render nested comments using a recursive include. Here's a simplified version of my template:
{% ...
-1
votes
3
answers
160
views
How to decode nested numeric patterns in strings like 2[2[32]1[82]] in JavaScript?
I'm trying to solve a variation of the LeetCode "Decode String" problem in JavaScript. The adapted challenge could be formulated as:
Given an encoded string, return its decoded string.
The ...
-3
votes
1
answer
107
views
How to convert call of a python object's nested attributes to string while returning a value?
I have trouble resolving a recursion issue, how can I build a class which would behave like this:
print the requested attributes from it: o.foo.bar would print "o.foo.bar" when called.
same ...