March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,9 @@
10 P$(0) = STR$(5)
20 P$(1) = "MARY"
30 P$(2) = "HAD"
40 P$(3) = "A"
50 P$(4) = "LITTLE"
60 P$(5) = "LAMB"
70 GOSUB 90"VARIADIC FUNCTION
80 END
90 FOR I = 1 TO VAL(P$(0)) : ? P$(I) : P$(I) = "" : NEXT I : P$(0) = "" : RETURN

View file

@ -2,22 +2,22 @@ import std.stdio, std.algorithm;
void printAll(TyArgs...)(TyArgs args) {
foreach (el; args)
writeln(el);
el.writeln;
}
// Typesafe variadic function for dynamic array
void showSum1(int[] items...) {
writeln(reduce!q{a + b}(0, items));
items.sum.writeln;
}
// Typesafe variadic function for fixed size array
void showSum2(int[4] items...) {
writeln(reduce!q{a + b}(0, items));
items[].sum.writeln;
}
void main() {
printAll(4, 5.6, "Rosetta", "Code", "is", "awesome");
writeln();
printAll(4, 5.6, "Rosetta", "Code", "is", "awseome");
writeln;
showSum1(1, 3, 50);
showSum2(1, 3, 50, 10);
}

View file

@ -12,6 +12,4 @@ void logObjects(id firstObject, ...) // <-- there is always at least one arg, "n
// This function can be called with any number or type of objects, as long as you terminate it with "nil":
logObjects(@"Rosetta", @"Code", @"Is", @"Awesome!", nil);
logObjects([NSNumber numberWithInt:4],
[NSNumber numberWithInt:3],
@"foo", nil);
logObjects(@4, @3, @"foo", nil);

View file

@ -1 +1 @@
f(a[..])=prod(i=1,#a,a[i])
f(a[..])=for(i=1,#a,print(a[i]))

View file

@ -0,0 +1 @@
printAll( List ) :- forall( member(X,List), (write(X), nl)).

View file

@ -0,0 +1,3 @@
execute( Term ) :-
Term =.. [F | Args],
forall( member(X,Args), (G =.. [F,X], G, nl) ).