Page 4 of 5
Re: it is about time...
Posted: Tue Jan 24, 2017 3:36 am
by KG_is_back
110 wrote:right, there were more errors like that, they just didnt show up as errors as inputs were missing and stuff.
so now here...
Code: Select all
output (Math.log(@f1))
def Math.log(*p)
log(*p)
end
output (log(@f1))
nice try, 110, but "stack level too deep". hmpf.
you have it the other way around.
Code: Select all
def log(*p) #the definition of your new function
Math.log(*p) #the execution code
end
in C it would look like this, just to see what we're doing:
float log(*args)
{
return Math.log(*args);
}
110 wrote:interesting!

so i know two working methods now to choose from.
here is the next issue. for noise with chi distribution i need to trigger this
((Math.sqrt(-2.0*Math.log(1.0-(rand))))*(Math.cos((rand)*6.283185307))**2.0)
for n times and accumulate the result.
no idea how to do that in ruby - and no idea how to make 5 consecutive triggers from 1 outside the ruby object.
both would be a good exercise.
https://www.tutorialspoint.com/ruby/ruby_loops.htmalso there is a very useful way to do it using ".each" method on objects that can be iterated (Array, Range, etc.)
Here are several examples:
Code: Select all
#using Range object. passing .each method executed the code in {} brackets once for each integer in the range
(0...100).each{
|i| #this line is optional - it puts current value into variable i
#your code
}
#same as the one before, but it return array containing all the results.
(0...100).map{
|i|
#your code
}
#or alternatively, this does the same as above.
Array.new(100){
|i| #index within the array
#your code
}
Re: it is about time...
Posted: Tue Jan 24, 2017 4:12 am
by 110
KG_is_back wrote:you have it the other way around.
thanks! not yet sure if i should do this to all functions in question, but it is good to learn anway.
will try the iterations stuff later.
another day i go for variables and my beloved comparisons and then i should have most things i need for a start.
Re: it is about time...
Posted: Tue Jan 24, 2017 4:52 am
by 110
chiiiiise...
Re: it is about time...
Posted: Tue Jan 24, 2017 5:19 am
by RJHollins
once again ... a BIG THANKS to You Guys for posting this evolution, and sharing.
More than just the 'CODE' ... I feel it so important to read, and get a sense of the 'thinking' that
Programmers exhibit. [if that makes sense ... it does do me]. Now to try and understand/learn.
Thanks

Re: it is about time...
Posted: Tue Jan 24, 2017 8:23 pm
by 110
so i´ve ben readin up on comparisons for an hour but i dont get it.
is there no simple method to compare two values and have it return a value?
i am writing small expressions using conditoinal statements like 300 * (a>0) + 500 * (a<=0) all the time, it is far more straight forward than splitting it up into 4 processes and use some kind of if type of statement... but 300 really wants to be multiplicated with 0 and 1 and doesnt really want to connect with "true".
Re: it is about time...
Posted: Tue Jan 24, 2017 8:33 pm
by 110
found this.
Code: Select all
output (@f1 == 7.0 ? 1.0 : 0.0) * 5
how can i shorten it further?
Re: it is about time...
Posted: Tue Jan 24, 2017 8:47 pm
by 110
hm okay comparison?1:0
Re: it is about time...
Posted: Tue Jan 24, 2017 9:52 pm
by 110
logic gates with up to 8 inputs
Re: it is about time...
Posted: Tue Jan 24, 2017 10:18 pm
by 110
is there a console or console object in flowstone where i can see what data came through and, if possible, of what type it was?
Re: it is about time...
Posted: Wed Jan 25, 2017 12:51 am
by 110
this time hopefully without bugs