Active object: Difference between revisions

add FreeBASIC
(Add Common Lisp implementation)
(add FreeBASIC)
Line 1,132:
>>> -0.000769965989580346
Press any key to continue...
 
=={{header|FreeBASIC}}==
<lang freebasic>#define twopi 6.2831853071795864769252867665590057684
dim shared as double S = 0 'set up the state as a global variable
dim shared as double t0, t1, ta
 
function sine( x as double, f as double ) as double
return sin(twopi*f*x)
end function
 
function zero( x as double, f as double ) as double
return 0
end function
 
sub integrate( K as function(as double, as double) as double, f as double )
'represent input as pointers to functions
t1 = timer
s += (K(t1,f) + K(t0,f))*(t1-t0)/2.0
t0 = t1
end sub
 
t0 = timer
ta = timer
 
while timer-ta <= 2.5
if timer-ta <= 2 then integrate( @sine, 0.5 ) else integrate( @zero, 0 )
wend
 
print S
</lang>
{{out}}<pre>
8.926050531860172e-07
</pre>
 
=={{header|Go}}==
781

edits