| Algorithms |
|
Others |
|
Compute the sum of the elements of an array
const func integer: sumArray (in array integer: valueArray) is func result var integer: sum is 0; local var integer: value is 0; begin for value range valueArray do sum +:= value; end for; end func;
Compute the product of the elements of an array
const func integer: prodArray (in array integer: valueArray) is func result var integer: prod is 1; local var integer: value is 0; begin for value range valueArray do prod *:= value; end for; end func;
List headlines from BBC
$ include "seed7_05.s7i"; include "gethttps.s7i"; include "strifile.s7i"; include "scanfile.s7i"; include "console.s7i"; include "html_ent.s7i"; const proc: main is func local var file: htmlFile is STD_NULL; var string: symbol is ""; begin OUT := STD_CONSOLE; htmlFile := openStriFile(getHttps("www.bbc.com")); symbol := getXmlTagHeadOrContent(htmlFile); while symbol <> "" do if startsWith(symbol, "<") then skipXmlTag(htmlFile); if symbol = "<h2" then writeln(decodeHtmlEntities(getXmlTagHeadOrContent(htmlFile))); end if; end if; symbol := getXmlTagHeadOrContent(htmlFile); end while; end func;
|
|
|
