Skip to main content
-1 votes
2 answers
101 views

I have a function where one of the variables is either a function x(t) or sometimes, for convenience, I'll be using x_t:=x(t) The following is pretty emblematic of what I'm up to: def foo(t,y,x): ...
learningjulia83's user avatar
-4 votes
3 answers
151 views

I'm learning about higher-order functions, specifically lambda functions in Python. I understand lambda functions to an extent, but a little confused about this lambda higher-order function example. ...
Cordev87's user avatar
0 votes
1 answer
75 views

The NextJS app has two HOFs that each inject data into a function param. The resulting function is exported as an Api route. It has the error: Server Actions must be async functions. Here is the ...
1192805's user avatar
  • 1,126
0 votes
2 answers
250 views

Recently to better understand the advantages and disadvantages of lazy evaluation, I check for some details of Haskell. I did that to do exercise 5.9 in SDF (Software Design for Flexibility) More ...
An5Drama's user avatar
  • 762
2 votes
0 answers
97 views

Let's say we have a function that applies a parameter to its input function fn apply_fn<'a, F>(f: F) where F: Fn(&mut u32), { let mut i = 1; f(&mut i); } This works as ...
tolvanea's user avatar
0 votes
4 answers
453 views

Now that I'm living completely in a Swift 6 async/await world, I've suddenly hit a snag. When writing code of this sort (never mind what it does, just look at the form of the thing): let result = ...
matt's user avatar
  • 540k
0 votes
1 answer
80 views

I am using ANTLR 4, and it is common to instantiate a class and immediately pass it as the argument of the next class' constructor, as per the docs for the ANTLR 4 JavaScript target: import antlr4 ...
James Baw's user avatar
0 votes
1 answer
43 views

I am writing a program that will playback a list of frames as a movie. But before it play it back I want to apply a modifier procedure to every frame in the list. for some reason when calling the ...
Gulez's user avatar
  • 1
1 vote
1 answer
97 views

Below is a minimal transduce implementation, but its output type is incorrect. Looking for what needs to change to correct it. Here's the example in a TS Playground containing transduce and all ...
Adam's user avatar
  • 2,917
1 vote
1 answer
38 views

How to get this reduce function to return type Set<1>? (Playground) const toSet = <const V>(acc=new Set<V>(),v:V) =>{ acc.add(v); return acc; } const set = toSet(undefined,1); ...
Adam's user avatar
  • 2,917
1 vote
1 answer
207 views

If I wanted to generate a polynomial function in Rust, one way to do it is the following, fn new_polynomial(vec: Vec<i32>) -> impl Fn(i32) -> i32 { move |x| vec.iter().fold(0, |acc, a| ...
James Baw's user avatar
0 votes
2 answers
123 views

I'm kinda confused with the usage of <stdarg.h> features. I can't figure out how to properly pass a va_list to the argument function. Here's a simplified example of what I'm trying to achive: #...
yurich's user avatar
  • 157
1 vote
2 answers
348 views

TypeScript does not infer properly the generic type of a function that accepts a function that exposes as its argument a function that when called should be provided with an argument that is generic. ...
Amin NAIRI's user avatar
  • 2,534
3 votes
0 answers
38 views

Is there a workaround in typescript to have a predicate on a higher-order function? type One = { _type: 'one'; value: unknown; }; type Two = { _type: 'two'; value: unknown; }; type ...
Janek Eilts's user avatar
8 votes
1 answer
400 views

The following non-templated (or is it?) function returning a non-generic, stateful lambda, auto foo(double a) { return [a](double b) -> double { return a + b; }; } compiled down to ...
Enlico's user avatar
  • 30.4k

15 30 50 per page
1
2 3 4 5
108