Jump to content

Apply a callback to an array: Difference between revisions

no edit summary
m (Automated syntax highlighting fixup (second round - minor fixes))
No edit summary
Line 1,464:
map (+1) [1,2,3] -- [2,3,4]
</syntaxhighlight>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
 
include "NSLog.incl"
 
void local fn Callback( n as NSInteger )
NSLog( @"Square root of %ld = %f", n, sqr(n) )
end fn
 
void local fn DoIt
NSUInteger i, count
CFArrayRef array = @[@1, @2, @3, @4, @5, @6, @7, @8, @9, @10]
 
count = len(array)
for i = 0 to count -1
fn Callback( fn NumberIntegerValue( array[i] ) )
next
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
{{out}}
<pre>
Square root of 1 = 1.000000
Square root of 2 = 1.414214
Square root of 3 = 1.732051
Square root of 4 = 2.000000
Square root of 5 = 2.236068
Square root of 6 = 2.449490
Square root of 7 = 2.645751
Square root of 8 = 2.828427
Square root of 9 = 3.000000
Square root of 10 = 3.162278
</pre>
 
 
 
 
 
 
 
 
=={{header|Fōrmulæ}}==
715

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.