Computer Science Canada

Assigning Arrays

Author:  AzureFire [ Wed Nov 30, 2005 6:00 pm ]
Post subject:  Assigning Arrays

Is there a way to set every value of an array all at once?
I need to set them all to false, so after a condition is met, they can be set to true.

Author:  MysticVegeta [ Wed Nov 30, 2005 6:03 pm ]
Post subject: 

code:
for x : 1..upper(arr)
arr(x) := false
end for

Author:  Cervantes [ Wed Nov 30, 2005 6:09 pm ]
Post subject: 

Also, look into init.

code:

var my_array : 1 .. 5 of int := init (3, 7, 42, 8, 4)

Author:  AzureFire [ Wed Nov 30, 2005 6:13 pm ]
Post subject: 

thanks, that was nice and fast Smile

Author:  wtd [ Thu Dec 01, 2005 2:13 pm ]
Post subject: 

code:
let my_array = Array.init 5 (fun _ -> false)


Oh, right, Turing. Wink


: