|
FISH ANNOUNCEMENT | ||||||||||
|
Poly-dimensionality
map : (a -> b) -> [a] -> [b]
and so may act on a vector, matrix or higher-dimensional
array. However, the existence of the simple imperative features means
that this can be compiled into a sequence of nested for-loops
corresponding to the number of dimensions of the array argument.
Polydimensionality is a form of shape polymorphism.
ExampleAn example of this programming style is the generic difference equation solver. An application of this is the little program hotspot.fsh intended as a crude model of a warm plate in a cold environment. Here are the results when applied to a vector of length 4, and 3x4 matrix and a 2x3x4 array.
>-|> %run hotspot1;;
fill { 4 : float_shape }
with [
5.752120,8.598921,8.598921,5.752120
]
>-|> %run hotspot2;;
fill { 3,4 : float_shape }
with [
2.429224,3.253875,3.253875,2.429224,
3.055436,4.238389,4.238389,3.055436,
2.429224,3.253875,3.253875,2.429224
]
>-|> %run hotspot3;;
fill { 2,3,4 : float_shape }
with [
1.546959,1.847372,1.847372,1.546959,
1.797130,2.233605,2.233605,1.797130,
1.546959,1.847372,1.847372,1.546959,
1.546959,1.847372,1.847372,1.546959,
1.797130,2.233605,2.233605,1.797130,
1.546959,1.847372,1.847372,1.546959
]
hotspot3 should be visualised as 2 3x4 matrices, each with
central entries of 2.23.
|
||||||||||
|
Last Updated: |
![]()
Main |
Announcement |
Latest Paper |
Distribution |
Tutorial Please feel free to send any comments.
Copyright Barry Jay © 1998
|