- Subject: [slang-users] Working with S-Lang arrays
- From: Duke Normandin <dukeofperl@xxxxxxxxxxx>
- Date: Thu, 22 Nov 2012 08:23:58 -0700
Hello list ...
The code below is some initial attempt at working with arrays, and
the S-Lang language in general.
Is the code substantially correct, or is it indicating that I may be
heading for a punji-pit??
As well, I see that S-Lang has several ways of sending output to
screen - print; printf; message; vmessage. The `print' function
works to output numeric data only (it seems). However, I can't find
any docs on it?
-----------------------------------8<----------------------------------
#!/usr/bin/env slsh
% This is a comment
variable i;
variable a = @Array_Type(Integer_Type, [10]);
a[[0:4]] = 11;
a[[5:9]] = 22;
% compare using "_for" - vs- "where" to edit array elements
message("At init-time, the array contains:");
print(a);
_for i (0, length(a)-1, 1)
if (a[i] < 12)
a[i] = 10;
message("the array now contains:");
print(a);
message("After using the \"where\" construct, the array now
contains:");
a[where (a < 11)] = 11;
print(a);
% Let's see if "where" can be used like "foreach"
message("\Walking\" through an array with \"where\" ...");
print( a[where (a)] );
------------------------------------------8<------------------------------
Thanks ...
--
Duke
[2012 date index]
[2012 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]