SCILAB Script - 12 Days of Christmas
Posted: Thu Dec 27, 2012 4:46 pm
Here is a sample script I found on-line a wile ago that shows the abilities of array manipulations in SCILAB. It produces all the verses of the 12 days of Christmas. Very interesting.
the_verses={'A partridge in a pear tree.'; 'Two turtle doves, and ' ;
'Three French hens, '; 'Four calling birds, ' ;
'Five golden rings, '; 'Six geese a laying, ' ;
'Seven swans a swimming, '; 'Eight maids a milking, ' ;
'Nine ladies dancing, '; 'Ten lords a leaping, ' ;
'Eleven pipers piping, '; 'Twelve drummers drumming, '};
the_days={'first';'second';'third';'fourth';'fifth';'sixth';
'seventh';'eighth';'ninth';'tenth';'eleventh';'twelfth'};
for day=1:12
printf('On the %s day of Christmas my true love gave to me:\n', the_days(day));
presents = the_verses(day1);
printf('%s\n', presents(:));
printf('\n');
end
the_verses={'A partridge in a pear tree.'; 'Two turtle doves, and ' ;
'Three French hens, '; 'Four calling birds, ' ;
'Five golden rings, '; 'Six geese a laying, ' ;
'Seven swans a swimming, '; 'Eight maids a milking, ' ;
'Nine ladies dancing, '; 'Ten lords a leaping, ' ;
'Eleven pipers piping, '; 'Twelve drummers drumming, '};
the_days={'first';'second';'third';'fourth';'fifth';'sixth';
'seventh';'eighth';'ninth';'tenth';'eleventh';'twelfth'};
for day=1:12
printf('On the %s day of Christmas my true love gave to me:\n', the_days(day));
presents = the_verses(day1);
printf('%s\n', presents(:));
printf('\n');
end