Anonymous functions use a block of code as a value, defining it as an inline function without a name.
Questions tagged [anonymous-function]
2121 questions
0
votes
0 answers
How do i write longer/complicated anonymous functions
I have a python function that I can pass a function argument in 2 ways as shown below.
Lambda:
res = foo(lambda x: x+2)
Regular function passing:
def func1(x):
return x + 2
res = foo(func1)
But I want to pass a slightly complex function to foo…

sgowd
- 946
- 3
- 10
- 27
0
votes
2 answers
Node.js Access Values from Anonymous function
Good morning!
I've been struggling to get a specific value returned from my function:
const getFolders = function (PID){
var token = getStoredToken()
request.get({
url: 'https://api.procore.com/vapid/folders',
headers: {
…

TeaSeaPea_IP
- 3
- 1
0
votes
1 answer
Encountering error when using anonymous function in template
I am encountering an anonymous function error when using template. I want to create a function and have a parameter pass to it. This should be simple but I am getting error. If I don't use template and just replace the actual type than the…

tadpole
- 1,209
- 7
- 19
- 28
0
votes
0 answers
IndentationError: unindent does not match any outer indentation level/ Anonyme Code
I don't understand this error. I have 4 spaces indentation.
It's my code
import discord
import asyncio
from discord.ext import commands
TOKEN = "My Token bot here"
bot = commands.Bot(command_prefix="!")
@bot.event
async def on_ready():
…
0
votes
1 answer
Anonymous function in Python(lambda)
I was looking but I don't understand in a practical way the difference between an anonymus function and a normal function.
Anonymuos function in python(lambda):
triangle_area = lambda base, height: (base, height) / 2
Normal function:
def…

Ivan Torres
- 1
- 1
0
votes
0 answers
Defining anonymous functions by value instead of by reference
Within a loop, I'm building a collection of anonymous functions. The problem is that I want to define each function in terms of the current value of the variable I'm looping over, but when this variable changes, the function retrospectively changes…

user326210
- 101
0
votes
3 answers
JavaScript anonymous function simulating arithmetic in lambda calculus, result returns `undefined`
I was intended to use javascript closure to simulate basic arithmetic in lambda calculus, to define 3 = 1 + 2
like this:
0 := λf.λx.x
1 := λf.λx.f x
2 := λf.λx.f (f x)
3 := λf.λx.f (f (f x))
It should print three times hello world, now it prints…

Yossarian42
- 1,950
- 17
- 14
0
votes
0 answers
Dynamically generated partial applications of a function to be passed to a struct as function pointers
So basically I am a complete beginner to a C++ but I have to face this complicated problem.
I basically have to design some strategy to a simple "dice poker game" similar to the one from Witcher. I came up with a strategy that relies on 4 parameters…

Adam Bajger
- 523
- 7
- 20
0
votes
1 answer
Save the data received from an anonymous function in a class object
I am trying to store the data I receive from a Facebook API call into a class property.
My constructor:
function Foo() {
this.bar = {
likes: 0
};
}
Method to update the object:
Foo.prototype.update = function() {
…

Shirak
- 65
- 2
- 7
0
votes
1 answer
Can wildcard anonymous functions be used when parameters are repeating in the result expression?
Find Square of an integer 'x'.
Without Placeholder
var square = (x:Int) => x*x
square(3) gives desired output 9.
With Placeholder var square = (_:Int)*(_:Int)
square(3) gives Error
Not enough arguments for method apply: (v1: Int, v2: Int)Int in…

NSH
- 11
- 1
- 4
0
votes
1 answer
Is anonymous function in Vue Template a performance killer?
I have following setup:
In Child component:
In Parent…

mitchK
- 37
- 2
- 6
0
votes
1 answer
Getting external params into anonymous function jQuery
I'm working on a function that will return a context menu for use within a jsTree (http://www.jstree.com/documentation/contextmenu) context. In setting up the context menu object, I need to somehow get some vars into a wrapped call to another…

notbrain
- 3,366
- 2
- 32
- 42
0
votes
3 answers
Modifying a variable passed to a PHP anonymous function doesn't appear to be reflected in variables original scope
I'm passing a variable into anonymous function (closure) via use, and within the closure body I'm modifying the variables value:
$myVar = false;
$myAnonFunc = function() use ($myVar) {
$myVar = true;
};
$myAnonFunc();
echo '$myVar => ' . ($myVar…

Dan Stevens
- 6,392
- 10
- 49
- 68
0
votes
0 answers
Undefined anonymous function when declaring more than one function with javascript
I'm new to JS and trying to use anonymous functions. I have two simple anonymous functions that work perfectly by themselves, but as soon as I put them both in the script I get the "ReferenceError: checkAnswer_js is not defined" message. Why does…
0
votes
1 answer
How can I pass an anonymous function to a Celery task? (Or accomplish my goal some other way?)
I have a file-downloading Celery task. More than one method in my main application is going to use this task and I'm trying to abstract it so the same task can be used for different purposes. At one point in my task I had
if r.ok:
results…

Katie
- 808
- 1
- 11
- 28