Questions tagged [function-call]

A function call is a line of code that executes a specific block of code defined as a function, that is, self-contained code that may optionally take arguments, defined for the purpose of code reuse.

A function call is a line of code that executes a specific block of code defined as a function, that is, self-contained code that may optionally take arguments, defined for the purpose of code reuse.

760 questions
3
votes
1 answer

Argument in fuction call inside function definition is not being replaced in Maxima

The problem Consider the following script written in Maxima $ cat main.max foo(a) ::= block( if a = 0 then return(0) else return(1) )$ bar(a) ::= block( return(foo(a)) )$ foo(0); bar(0); Executing this script yields to $ cat main.max |…
gfe
  • 157
  • 5
3
votes
2 answers

How to call through pointer-to-member function saved in a container?

I am trying to write a member function that calls other member functions of the same object in turn until one of them works. I would like to write this as below: class myClass { bool A() { return false; } bool B() { return false; } bool C()…
3
votes
3 answers

The centroid of a list of points

New to Haskell The problem is -- The centroid of a list of points is a point whose x (and y) coordinates are -- the means of the x (and y) coordinates of the points in the list. -- -- You may assume the list contains at least one point. -- -- >…
Lmmmmmmc
  • 87
  • 2
3
votes
4 answers

Bash. Return two function levels (two nested calls)

I need to know if Bash has some solution for my case. I need after some conditions to do a "double return". I mean, to perform a return of a function and also return the parent function to skip the rest of the code of that parent function. I know…
OscarAkaElvis
  • 5,384
  • 4
  • 27
  • 51
3
votes
1 answer

How to do type checking for a recursive function with no explicit return type?

I am writing a language where functions are not typed. Which means I need to infer the return type of a function call in order to do type checking. However when somebody writes a recursive function the type checker goes into an infinite recursion…
3
votes
1 answer

Is an Incremented Variable Reusable in a tie Call?

So I understand that re-usage of a variable that has been post incremented is undefined behavior in a function call. My understanding is this is not a problem in constructors. My question is about tie which is oddly halfway between each. Given:…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
3
votes
2 answers

Why the sentence "The expression can be used only as the left-hand operand of a member function call" in [expr.ref]p(6.3.2)?

[expr.ref]p(6.3.2): Otherwise, if E1.E2 refers to a non-static member function and the type of E2 is “function of parameter-type-list cv ref-qualifieropt returning T”, then E1.E2 is a prvalue. The expression designates a non-static member…
Belloc
  • 6,318
  • 3
  • 22
  • 52
3
votes
3 answers

How to use ternary operator to select function

The following snippet works if (condition) node.addClass('myclass'); else node.removeClass('myclass'); but not this one node[condition ? 'addClass' : 'removeClass']('myclass'); nor this one (condition ? node.addClass :…
SU3
  • 5,064
  • 3
  • 35
  • 66
3
votes
3 answers

How I can make a string array interchange it's components with a swap function?

The problem is that this code won't interchange these 2 strings. I'm new to programming but I can tell that the problem is that swap function, but I do not know how to fix it. I tried to add strcpy instead of "=" in swap but that didn't…
Andrew
  • 63
  • 4
3
votes
2 answers

passing multiple arguments in python on a loop

I have a function that takes multiple arguments of tuples and process it accordingly. I was wondering if I can pass the arguments in a for-loop. For example: def func(*args): for a in args: print(f'first {a[0]} then {a[1]} last…
JediBig
  • 51
  • 1
  • 4
3
votes
3 answers

Why is a Common-Lisp Lambda expression a valid function name?

So let's say I want to call some function. If I've defined the function with a defun, I just use the name of the function at the beginning of a list followed by it's arguments like so (I will be using "=>" in examples to show the output of entering…
Charlim
  • 521
  • 4
  • 12
3
votes
2 answers

What is faster: noop function call or if statement?

I got a function pointer for a deleter, but most of the time, the deleter is not gonna be needed, only when I maintain an internal copy of something. Currently I do that with a noop deleter function: class MyClass{ public: // bind object …
Xeo
  • 129,499
  • 52
  • 291
  • 397
3
votes
3 answers

What does using a function name without parentheses do in an if statement in JavaScript?

For example: function foo (parameter1, parameter2) { // does something } if (foo) { foo(parameter1, parameter2); } Calling a function without parentheses was talked about in a different question (In JavaScript, does it make a difference if…
H Gent
  • 35
  • 7
3
votes
1 answer

Is it good to make methods return 'self' for chaining method calls?

I have a class, for example: class Example: def __init__(self): self.x = 1 def add(self): self.x += 1 return self If I want to chain methods, I can use: my_example = Example() my =…
Dinko Pehar
  • 5,454
  • 4
  • 23
  • 57
3
votes
1 answer

What do these parentheses mean when calling an object?

Just came across this statement and was wondering why this function call had what at first looked like a cast? SomeClass bo = new SomeClass(); // blabla something like that to initialize the object variable (bo).setValue(bo.getValue().negate()); As…
PhiSe
  • 33
  • 3