Apply a callback to an array: Difference between revisions

No edit summary
Line 1,490:
HandleEvents
</syntaxhighlight>
 
Another option is to enumerate the array.
<syntaxhighlight lang="futurebasic">include "NSLog.incl"
 
void local fn Callback( array as CFArrayRef, obj as CFTypeRef )
long value = intVal(obj)
NSLog( @"Square root of %ld = %f", value, sqr(value) )
end fn
 
void local fn DoIt
CFArrayRef array = @[@1, @2, @3, @4, @5, @6, @7, @8, @9, @10]
ArrayEnumerateObjects( array, @fn Callback, NULL )
end fn
 
fn DoIt
 
HandleEvents</syntaxhighlight>
 
{{out}}
<pre>
Line 1,503 ⟶ 1,521:
Square root of 10 = 3.162278
</pre>
 
 
 
 
 
 
 
 
=={{header|Fōrmulæ}}==
416

edits