Skip to content

Instantly share code, notes, and snippets.

@antranigv
Created May 16, 2017 17:32
Show Gist options
  • Save antranigv/087154dae1cada0a8965e88ca725ac0c to your computer and use it in GitHub Desktop.
Save antranigv/087154dae1cada0a8965e88ca725ac0c to your computer and use it in GitHub Desktop.
MODULE subsum;
IMPORT Out, Modules;
VAR s : POINTER TO ARRAY OF LONGINT; i : LONGINT;
PROCEDURE Check ( a : ARRAY OF LONGINT ) : BOOLEAN;
VAR i , sum : LONGINT;
BEGIN
sum := 0;
FOR i:=0 TO LEN(a) - 1 DO
IF a[i] = 0 THEN RETURN TRUE END;
sum := sum + a[i];
END;
Out.Int(sum, 0); Out.Ln;
IF sum = 0 THEN RETURN TRUE ELSE RETURN FALSE END;
END Check;
BEGIN
NEW(s, Modules.ArgCount - 1);
FOR i:=0 TO LEN(s^) - 1 DO
Modules.GetIntArg(SHORT(i) + 1, s^[i]);
END;
Out.String("Hello World"); Out.Ln;
IF Check(s^) THEN Out.String("True") ELSE Out.String("False") END; Out.Ln;
END subsum.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment