RosettaCodeData/Task/Bitmap/Oz/bitmap-1.oz

38 lines
627 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
functor
export
New
Get
Set
Transform
define
fun {New Width Height Init}
C = {Array.new 1 Height unit}
in
for Row in 1..Height do
2026-04-30 12:34:36 -04:00
C.Row := {Array.new 1 Width Init}
2023-07-01 11:58:00 -04:00
end
array2d(width:Width
2026-04-30 12:34:36 -04:00
height:Height
contents:C)
2023-07-01 11:58:00 -04:00
end
fun {Get array2d(contents:C ...) X Y}
C.Y.X
end
proc {Set array2d(contents:C ...) X Y Val}
C.Y.X := Val
end
proc {Transform array2d(contents:C width:W height:H ...) Fun}
for Y in 1..H do
2026-04-30 12:34:36 -04:00
for X in 1..W do
C.Y.X := {Fun C.Y.X}
end
2023-07-01 11:58:00 -04:00
end
end
%% omitted: Clone, Map, Fold, ForAll
end