416 questions
0
votes
0
answers
18
views
Why isn't my simple conversion program working when i call a function within a function? [duplicate]
def rods_to_meters(rods):
meters = rods * 5.0292#converts rods to meters and stores in appropriate variable.
return(meters)
def rods_to_feet(rods):
feet = (rods * 5.0292) / 0.3048#...
0
votes
0
answers
46
views
Headless mode while using Selenium webdriver won't perform function
This is a nested function inside a function that I defined. But somehow the webdriver in Headless mode just won't perform the xport.click function. This function WORKS on a regular window but won't in ...
0
votes
0
answers
21
views
A question related to function enclosure and call-by-name of Python language [duplicate]
Consider the following code snippet:
def part1():
flist = []
for i in range(10):
def hello():
print(f"Hello {i = }.")
flist.append(hello)
for f ...
1
vote
1
answer
85
views
Python generator yielding from nested non-generator function
This is a dumb example based on a more complex thing that I want to do:
from typing import Generator
def f() -> Generator[list[int], None, None]:
result = list()
result.append(1)
if len(...
1
vote
1
answer
219
views
Variables' scope of nested function in MATLAB
I am a little confused about the variables' scope in a nested function in MATLAB.
As nested function help docs explains: vaiable remains local to the nested function.
function main
nestedfun1
...
1
vote
2
answers
66
views
Acces to import of the nested function JS
I need some help to get how some function export works inside JS.
Let's say I have this code
function goodbuy() {
console.log('bye');
}
function myModule() {
function hello() {
console....
0
votes
1
answer
121
views
Using nested helper functions while building a class
I want to build a class which is merely a wrapper for some data. This is the basic idea:
class Fruits:
fruits = [ 'apple', 'orange', 'cherry' ]
My fruits aren’t strings, though, but classes ...
-1
votes
2
answers
72
views
Why won't calling a nested function result in returning original function's value? [closed]
Somehow I can't manage to use a previously defined function inside another one. Is that possible?
def generate_password(length):
import random
password = str()
alpha_num = [i for i in '...
0
votes
1
answer
32
views
Program output with nested function and function parameter
Given the following code
def alpha(num, proc):
def beta(): print(num)
if num == 1:
alpha(2, beta)
else:
proc()
def gamma():
pass
alpha(1, gamma)
I expected the ...
0
votes
1
answer
102
views
Python tkinter removing nested functions
So I was developing a GUI with tkinter and I have realised that I have so many nested functions in my code that I think it is not a good practice. However, I think my code will not work without using ...
1
vote
2
answers
240
views
R nested functions
I have to calculate the number of missing values per observation in a data set. As there are several variables across multiple time periods, I thought it best to try a function to keep my syntax clean....
0
votes
1
answer
812
views
TypeError: function() missing 1 required positional argument: 'y'
I want the greet function to say "Hi Sam, Hi Cody" using the format function but I am getting this error:
greet(names())
TypeError: greet() missing 1 required positional argument: 'y'
def ...
-2
votes
2
answers
924
views
Why do I get error "missing 1 required positional argument"?
Why I continue getting the error :
missing 1 required positional argument: 'category_id'
when the argument is already passed within query function in Backend class? I also don't understand the error ...
0
votes
1
answer
183
views
Variable declared and assigned at global scope is undefined when called by a nested return function
When a function is created inside a function, the following code is returning a string with the name variable coming back as undefined. Since this is functionally scoped inside the global scope, I ...
0
votes
1
answer
738
views
In R, how to write a nested function that uses the arguments from the outer function?
f1<-function(x,y){
f2<-function(a,b){
print("f2")
return(a+b)}
f2(x,y)
print("f1")
return(x-y)}
f1(8,5)
I was trying above code to figure ...
3
votes
1
answer
158
views
Returning value in a nested function when using memoization
I am trying to implement a count variable in the function below using dynamic programming specifically memoization. The method calculates the value in a Fibonacci sequence at a given index. I cannot ...
15
votes
1
answer
2k
views
With c# why are 'in' parameters not usable in local functions?
For example,
public int DoSomething(in SomeType something){
int local(){
return something.anInt;
}
return local();
}
Why does the compiler issue an error that the something variable cannot ...
0
votes
1
answer
662
views
VS Code C extension doesn't support GCC nested functions
I edit my C code with VS Code (1.17.0) with C/C++ Extension (1.12.0) that provides error checking. I compile my code with GCC compiler that supports nested functions. So if I write this
int foo(int x)
...
-1
votes
1
answer
60
views
Calling a nested function with a string (window[]) in JS [duplicate]
How to call a nested function with only a string? eg:
function oot(wha) {
function inn(wha)
{
First.innerHTML+="Inner ["+wha+"]";
}
oot....
0
votes
1
answer
44
views
In nested functions only the first function works
I've never used the nested functions before, and this seemingly simple task is giving me trouble. When I run this code only the first function work, and the second is completely unresponsive.
const ...
-1
votes
4
answers
135
views
Using a function as function parameter
I tried to write a nested function to calculate the area. However, the program showed the name circle is not defined.
Could anyone please help providing a suggestion about this nested function ...
63
votes
1
answer
4k
views
Why does std::fs::write(...) use an inner function?
I'm new to Rust and have been looking through the source code a bit, and found this:
#[stable(feature = "fs_read_write_bytes", since = "1.26.0")]
pub fn write<P: AsRef<Path&...
0
votes
2
answers
879
views
memoization function in javascript
So I came across a momoize function when I was trying to understand how memoization really works, the solution has really had me thinking, the code below
const memoize = (fn) => {
const cache ...
0
votes
1
answer
127
views
Python nested currying
I was trying to solve a codewars problem here, and I got a bit stuck. I believe I should be using nested currying in Python.
Let us just take the case of add. Let us constrain the problem even more, ...
0
votes
5
answers
258
views
NodeJS - Call Nested Function from inside another nested Function
i have two nested functions, i want to call the second one inside the first one but i nodejs doesn't seem to recognize it.
function Main(){
this.NestedA = function(){
console.log('Hello from A')
...