Basic HTML version of Foils prepared March 30 97

Foil 18 Arrays and Lists of Scalars(data) III -- Construction (Chapter 3 of Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


More complicatedly we can set constructed lists equal to each other
($a, @fred) = @fred; # sets $a to first element of @fred and removes this first element from @fred
($a,$b,$c) = (1,2,3); # sets $a=1, $b=2, $c=3
Curiously setting a scalar equal to an array returns length of array
$a = @fred; # returns $a as length of @fred whereas
The function length returns number of characters in a string
$a = length (@fred); # returns length in characters of first entry in @fred
($a) = @fred; # defines two lists equal to each other but as LHS only has one element, this instruction sets $a to be first entry of @fred



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Sep 6 1997