it is about time...

For general discussion related FlowStone
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: it is about time...

Post 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.htm

also 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
}


110
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Post 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.
110
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Post by 110 »

chiiiiise...
Attachments
chi.fsm
(760 Bytes) Downloaded 932 times
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

Re: it is about time...

Post 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
8-)
110
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Post 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".
110
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Post by 110 »

found this.

Code: Select all

output (@f1 == 7.0 ? 1.0 : 0.0) * 5


how can i shorten it further?
110
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Post by 110 »

hm okay comparison?1:0
110
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Post by 110 »

logic gates with up to 8 inputs
Attachments
110-8gates.fsm
(679 Bytes) Downloaded 1002 times
110
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Post 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?
110
Posts: 40
Joined: Mon Jan 16, 2017 3:20 pm

Re: it is about time...

Post by 110 »

this time hopefully without bugs
Attachments
110-8gates.fsm
(668 Bytes) Downloaded 922 times
Post Reply