Questions tagged [return-value]
Return value is the result of evaluation of a return statement.
4,462
questions
2
votes
2
answers
38
views
how to stop a func from running and return a value after one minute?
I would like to call a func and stop it from running after one minute, returning a value.
i have a code that looks similar to that:
def foo(txt):
best_value=-1
for word in txt:
if value(...
-1
votes
0
answers
13
views
How to get the variable value inside sigle quote by variable name using php [duplicate]
I need to get the value of the given variable name without quotes(''). Is it possible with php?
variableName='value'
I think using preg_match or regex... It is possible? But how?
Needed output as
...
1
vote
0
answers
15
views
python unable to unpack returned values from Octave function
I have a function called doFFT.m in Octave, defined as:
function [Rx1,Rx2,fbins]=doFFT(file)
this function runs as expected returning 3 row vectors.
In Python, I have oct2py imported,
from oct2py ...
0
votes
1
answer
21
views
What is functionality of the '[recur]' in 'return (None, [lng])[recur]'
I've solved this challange on CodeWars in the other way, and now I'm learning from other solutions. One of them is:
# Recursive solution
def sqInRect(lng, wdth, recur = 0):
if lng == wdth:
...
1
vote
1
answer
49
views
Why do I get an error when I overload the << on the object returned by the + operator overloaded function
class String
{
char* array;
public:
String(const char* s)
{
array = new char[strlen(s) + 1]{ '\0' };
strcpy(array, s);
}
~String()
{
if (array)
{...
0
votes
1
answer
32
views
Sheets Data Validation In Colum "O" is updated when Colum "P" values are +7
I have in Colum "O", on a dropdown list of two values (Yes, No).
I got a scrip running that every time I tick it to "Yes", in Colum "P" I get a timestamp of todays date.
...
0
votes
2
answers
86
views
boolean function returning false even though condition is satisfied to return true in c++. Why?
My function is a simple palindrome algorithm that is supposed to take an input integer (test), turn it into a string (test_s), then reverse that string in a new variable (test_s_reverse) then return ...
0
votes
3
answers
107
views
Why are integer return values (such as -1 or 0) used in C and C++?
When I read C or C++ code, I often notice that functions return integer values such as -1 or 0. My question is: why are these integer return values used?
It appears that -1 is returned by functions ...
-1
votes
1
answer
39
views
Why doesn't the function return the value?
I wrote this piece of code, why doesn't the first function return the value of the second one when I put it (consolePlay()) in the console?
function computerPlay() {
getRandomIntInclusive(1, 3)
}
...
0
votes
3
answers
77
views
why does returning the local variable address throws an error but returning the local variable value don't? [duplicate]
I can not understand, what is the difference between following function bodies
int func(void){
int A = 20;
return A;
}
and
int* func(void){
int A = 20;
return &A;
}
why returning ...
1
vote
0
answers
19
views
What is the purpose of rehashing?
What is the purpose of rehashing? if I were to explain this concept to a newcomer. How I could rephase this concept so they would understand?
0
votes
2
answers
69
views
C# find highest value in class object array without LINQ
This is for my school project and therefor I need to code without LINQ methods etc.
I'm trying to show which city has the highest temperature by finding the highest temp and then print it together ...
0
votes
1
answer
44
views
powershell return value $? and custom exit code [closed]
I installed powershell on Linux-Box.
At end of my *.PS1 file I put the following code:
Exit 2222
I run my ps1 file such as:
pwsh-lts -File my.ps1
But I can't access to 2222. How can I access it?
1
vote
3
answers
67
views
Returning dynamic memory inside a struct in C
Hi I have the following struct
typedef struct mystruct_s {
int* array;
} mystruct;
and I want to create a function that initializes it.
I have two ways of doing it.
First one is:
mystruct ...
10
votes
2
answers
1k
views
A question about returning local pointer variable in function
I know the variables in function are using stack space. When function exit, the space are freed. That's why we should declare the pointer variable as static in function. However, I found that the code ...
1
vote
1
answer
56
views
Trying to convert text into hex by calling a function within my batch file, but the hex code never gets returned to the Main batch function
@echo off
goto :main
:strg2hex
setlocal EnableDelayedExpansion
rem Store the string in chr.tmp file
set /P "=%~1" < NUL > chr.tmp
rem Create zero.tmp file with the same number of ...
0
votes
2
answers
55
views
Python: Returning a value from a method within a class
I am new so doing baby steps. Created a simple program of averaging heights.
No error message but return value is:
<function Students.total_heights at 0x00000207DC119750>
I didn't need to create ...
0
votes
1
answer
19
views
Returned value not expected - closures
I don't understand why it returns 0, it is supposed to increment by 1, is there something I don't know about closures?
let i = 0;
const getRenderValue = function() {
return i++;
};
...
1
vote
1
answer
37
views
How to add values in cells under an actual table
I need to add value in cells under different tables sizes, i think using offset under the table is a way to do it
This is my try:
Making a table as a object:
Sub LisObjectsTable()
Dim LR As Long
Dim ...
0
votes
0
answers
28
views
Return multiple values to script
In the script below I import some pictures that I want to segmentate. The segmentation is done withe the line:
mask = cv.inRange(blur0, low_yellow, high_yellow)
As you can see, normally the ...
0
votes
0
answers
15
views
Python return value in bash script [duplicate]
I have python script which is ran from bash script.
bash script
exit_code=$(python3 return_value.py)
echo $exit_code
if [[ $exit_code -eq 0 ]]
then
echo "OK"
elif [[ $exit_code -eq 1 ]]
...
2
votes
2
answers
47
views
If date is older than 6 months and value is X, then output this
I have two columns in excel, one with a date and one with a rating 'low, medium, high'.
I'm trying to write a formula to put in a third column that checks:
If A2 = Low and B2 (date) is older than 12 ...
0
votes
1
answer
27
views
Trouble getting and printing a returned value from one class to another in Java
I'm trying to import data from a CSV file. I don't have any issue about the importing process. But, when I'm passing an imported array from the CSV file to another method in another class, I can not ...
0
votes
2
answers
39
views
Python tkinter return value from function call in a button
Hello I'm new to python and I'm stuck I need help.
My problem is this:
I have a function that returns a string
I call this function in a button
How to get this value ?
My code :
from tkinter import*
...
1
vote
1
answer
26
views
vlookup "FALSE" returns 0 instead of cell value for some rows
[Cells that I am retrieving information from: Stranding log full_YS oh crap.xlsx]Infostats - sites'!$H:$J)
(Site= Gamtoos River Mouth; Lat= 33°58'03.1"S, Long= 25°02'47.8"E)]1
[Row 1: Site= ...
0
votes
0
answers
12
views
Return variable from mediastream js
I use hark to detect when user stops speaking, I simply want to return variable res from inside user stream to parent function stop; however I get undefined within navigator scope. TIA
function ...
-1
votes
0
answers
49
views
How can i access to an array returned by other function?
#I have this function to open two arrays of a txt file and create a table and an embedded graph in root. The problem is that i cannot access the matrix returned by this function in order to use it in ...
0
votes
1
answer
25
views
Make a class have function with 3 parameter (int,string,double ) with return value int in Kotlin
fun main() {
val thr = THR()
thr.kotlin()
thr.hitungthr(5000000, "1", 1.5)
}
class THR {
fun kotlin() {
println("Perhitungan THR")
}
fun hitungthr ...
1
vote
2
answers
94
views
Return of a func
Consider this code:
#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
Rectangle() {}
Rectangle (int x, int y) : width(x), height(y) {}
int ...
0
votes
3
answers
61
views
Problem with returning an array to a function in C
My problem is that I can't return the processed string to the function. The function's job is that it must accept a string, change its letters, and return the processed string to the function.
char *...
-2
votes
0
answers
21
views
Losing the return value in this struct member function? [duplicate]
Here's the class definition:
struct UnsignedBigInteger {
UnsignedBigInteger(const char* data_ptr) : data_ptr{ data_ptr } {
size_t size = sizeof(data_ptr);
if (size > length) ...
1
vote
2
answers
80
views
What do these return conditions do in a Boolean function?
On codecademy there exists a course on C, which includes a project on how to make a calendar. This project includes a boolean function which decides if a given year is a leap year or not. Code:
bool ...
-7
votes
2
answers
86
views
What actually is int in int main void in c? [duplicate]
#include<stdio.h>
#include<conio.h>
int main(){
printf("hello world");
}
What actually does int do to the main function? Is it similar to the data type int? What does conio....
-2
votes
0
answers
44
views
Return multiple values from a for loop to a user define function
First I generate a random number from a given range. Say the range is from 1 to 20. Say I got the random number 10. Then I create a function which can find out all the primes numbers from 2 to the ...
0
votes
0
answers
15
views
Loop sentences using return
Im trying to loop through sentences and tags_to_label contains array of position of words in the sentence e.g: Adam lemmington ate an apple so tag_to_label = [1 2] position of the nouns in the ...
0
votes
1
answer
27
views
Mysql - Return table from stored procedure into a variable?
Thanks to this answer https://stackoverflow.com/a/8180159/16349298 , i'm able to translate
a string into a temporary table (usable for WHERE <id> IN <tmpTable>.<colomn>)
The only ...
1
vote
1
answer
23
views
find() return the latest value only on MongoDB
I have this collection in MongoDB that contains the following entries. I'm using Robo3T to run the query.
{
"_id" : ObjectId("xxx1"),
"Evaluation Date" : "...
0
votes
0
answers
21
views
How is it better to test return value of preg_match in PHP? [duplicate]
I'm new in PHP. I'm writing a function in PHP that uses preg_match. The function works well, but reading the official documentation on
https://www.php.net/manual/en/function.preg-match.php I have a ...
1
vote
0
answers
17
views
Keras LSTM, training well with return_sequences=True and not with return_sequences=False
So I have a 2D sequence that I want to use to predict another 2D sequence (map them) like:
x = [6 7; 8 9; 9 0] and y = [4 5;3 4;5 6]
I was using the sliding window approach to have 5 inputs of x to ...
0
votes
1
answer
33
views
How to find a string with specific letters in gethash javascript function
function getHash( string ) {
let h = 7, letters = "acdefhlmnoprstuw";
for( var i = 0; i < string.length; i++ ) {
h = ( h * 37 + letters.indexOf( string[ i ] ) );
} ...
-2
votes
2
answers
34
views
How to get JSON value without knowing the key [duplicate]
I am faced with a problem, I want to obtain the value from a JSON property but the key is unknown when the request is made. I know I can stringify the JSON response and splice based on the ":&...
0
votes
3
answers
42
views
Kotlin function return with any one return type from two different data type without specifying Any as a return type?
I want to allow any one of these two return type (ApiResponse || ErrorResponse). But Return Type should not be a object or Any.
fun getAllUser() : Any? {
val flag = true
return if(flag){
...
2
votes
3
answers
135
views
Multiples of 10 in a list
I am currently doing an assignment in my intro level CS class and just need a smidge of help.
They are asking me to write a program that reads a list of integers and determines if it has;
multiples ...
-2
votes
1
answer
43
views
Stuck with php function not returning any data
I am expecting the below code to return hi when the project is run.But it's not returning anything .There is no error also.I've started the wamp server. How can i fix this?I'm very new to this. Anyone ...
0
votes
1
answer
31
views
Facing problem when return an array from a function in JavaScript
I am creating a function to fetch the latitude and longitude using navigator object and returning these two values using an array. The problem is that when I am trying to access one of them using ...
-2
votes
1
answer
28
views
can we validate multiple functions inside if condition with AND operator using java script is there any other way to check multiple functions true?
I have added these functions and need return something based which function is returning true but it is not working.
//this is function1/
function A() {
return true;
}
function B() {
return true;
...
1
vote
1
answer
40
views
How to output two values from the same function [duplicate]
Basically what the title says. I have this program:
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int letter_countf(string Text1);
int main(void)...
0
votes
0
answers
75
views
Hi. I have troubles with RETURN VALUE from THREAD function
My program must to search a file by name from some directory and search it through the threads!
Here I created TEMP folder for testing this search,included some different files and here searching for ...
-2
votes
1
answer
32
views
Do any programming languages provide the ability to name the return value of a function?
Quite commonly while programming I find it necessary to document the value that a function returns. In Java/Scala world, you often use comments above the function to do this.
However, this can stand ...
0
votes
2
answers
31
views
Angular Observable BehaviourSubject.getValue() returns normal value
I have this syntax:
const pageId = this._someService.currentData$<Data>().getValue().id;
which returns a normal string value with getValue() from the Observable (BehaviourSubject) currentPage$&...