How to return a Value from a Function back to the caller Function?

Dear Community,
I’m a bloody beginner.
So I have a rubbish, sadly rubbish Question and need important a Command :> Format C.
I have the Problem to return a Value from a called Function return to the caller. So it would been fine when there is anybody who can show me easy two Functions who the First call the second, And the second calculate anything and return it to the first.

So I’m rubish.
This Question is silly
But I think. This is the Point where I have the Problem to understand the Things right.

In hope of a kick in Ass

CreCo

We were all beginners once. This is a great place to ask questions of any level.

I don’t totally understand your question, but I think you are looking for this:

(

b = {|input|

input*3

};

a = {

15+b.value(10)

};

a.value

)

a calculates its value based on the value of b. If that isn’t what you are asking, let me know.

Sam

Dear Sam,
when this is right than I have done all correct by my self.
So I send you the Extract of a longer Supercollider Script.
Maybe you can find the mistake.
// Sives for MedianClalculation
// Sieve pass right Values
( ~mySieveI = { arg a, bound, eq;
var aa;
if( (a > (eq-bound)) && ( a < (eq+bound)))
{ aa = a }
{ aa = 0};
aa+0;
}; )

// Sieve count right Values
( ~mySieveII = { arg a, bound, eq;
var count=0;
a.do({ arg item, i;
if( (item > (eq-bound)) && ( item < (eq+bound)))
{ count = count + 1; }{};});
count+0;
}; )

// Processing Full Array to Median Value
( ~processingArray = { arg measureSeq;
var average, dirtyaver = 0,
average2, dirtyaver2 = 0,
averageres, dirtyavereres=0,
doubleStandardDer;
“Hello Median Calculation …”.postln;
measureSeq.do({ arg item, i; dirtyaver = dirtyaver + item; });
average = dirtyaver / measureSeq.size;
measureSeq.do({ arg item, i; dirtyaver2 = dirtyaver2 + abs(item - average).squared; });
average2 = dirtyaver2 / measureSeq.size;
doubleStandardDer = average2.sqrt*2;
measureSeq.do({ arg item, i; dirtyavereres = dirtyavereres + ~mySiveI.value(item, doubleStandardDer, average); });
averageres = dirtyavereres / ~mySiveII.value(measureSeq, doubleStandardDer, average);
“Hello23”.postln;
});

So when I out comment the bolted Lines it sems to run, When I do it not: I’m receive an Error that I would add a Null Value to a Number.

I hope you or another can PLEASE find my Mistake.

CreCo

You should add more postln’s to your code to help debug. I added some below to show you that your code is not calling mySieveI like you think. It is because you have spelled it wrong in line 37 - where you have spelled it ~mySiveI. There are still problems, but you should add lots of posting to your code so that you can find the problems.

Sam

( ~mySieveI = { arg a, bound, eq;

var aa;

if( (a > (eq-bound)) && ( a < (eq+bound)))

{

	"greater".postln;

	aa = a }

{

	"less".postln;

	aa = 0};

aa+0;

}; )

// Sieve count right Values

( ~mySieveII = { arg a, bound, eq;

var count=0;

a.do({ arg item, i;

	if( (item > (eq-bound)) && ( item < (eq+bound)))

	{ count = count + 1; }{};});

count+0;

}; )

// Processing Full Array to Median Value

( ~processingArray = { arg measureSeq;

var average, dirtyaver = 0,average2, dirtyaver2 = 0,averageres, dirtyavereres=0,doubleStandardDer;

("median").postln;

measureSeq.do({ arg item, i; dirtyaver = dirtyaver + item; });

average = dirtyaver / measureSeq.size;

measureSeq.do({ arg item, i; dirtyaver2 = dirtyaver2 + abs(item - average).squared; });

average2 = dirtyaver2 / measureSeq.size;

doubleStandardDer = average2.sqrt*2;

measureSeq.do({ arg item, i;

	[item, doubleStandardDer, average].postln;

	dirtyavereres = dirtyavereres + ~mySiveI.value(item, doubleStandardDer, average).postln; });

[measureSeq, doubleStandardDer, average].postln;

averageres = dirtyavereres / ~mySiveII.value(measureSeq, doubleStandardDer, average);

"hello23".postln;

});

~processingArray.value([1,2,3,4,5])

Oh,
Thanks now are more things will going clear for me.
I hope to find just the Mistake.
But please lough not about me …
… it’s my third try to do anything with Supercollider

Thank’s for the kick in my Ass.

CreCo :sweat_smile: :wink:

Oh dear,
its so silly. I need a new binocular.
You have right there a Such a stupid mistake.

CreCo which is so rubish.

:nauseated_face: :nauseated_face: :nauseated_face:

Hi CreCo! I’ve been in the situation of turning my code upside down, digging for hours (literaly), just to find a spelling mistake like that. Several times :sneezing_face:!

What I want to say is: format your code so that is easier to read :slight_smile:
This breaks down to many things, including:

  • consistently use camelCase or snake_case when making up variable names with multiple words
  • use meaningful variable names, avoiding things like a or x
  • use indentation consistently

Also, when posting code on the forum, remember to put it between three backticks:
```
your code here
```
This helps, among the other things, to preserve your indentation, so that your code is also easier to read here on the forum!

There are also some good tips about writing code here:

Love