Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Males, Sebastian
wacc_examples
Commits
b58a101a
Commit
b58a101a
authored
Mar 17, 2021
by
Jack Q
Browse files
Merge branch 'master' of gitlab.doc.ic.ac.uk:sm919/wacc_examples
parents
2a86f468
86caa57d
Changes
5
Hide whitespace changes
Inline
Side-by-side
invalid/semanticErr/function/lambdaWrongFuncPointer.wacc
0 → 100644
View file @
b58a101a
# Assigns wrong type to a lambda.
# Output:
# #semantic_error#
# Exit:
# 200
# Program:
begin
bool{int} f = (\(bool x) -> x)
end
invalid/semanticErr/function/lambdaWrongVariable.wacc
View file @
b58a101a
# Tries to use
i
nexistent variable in lambda.
# Tries to use
no
nexistent variable in lambda.
# Output:
# #semantic_error#
...
...
valid/function/lambdas/lambdaArray.wacc
0 → 100644
View file @
b58a101a
# Take a lambda which operates on a pair
# Output:
# 12
# Exit:
# 0
# Program:
begin
int[] a = [1,2,3];
int{int[]} x = (\(int[] arr) -> 4 * len arr);
int y = call x(a);
println y
end
\ No newline at end of file
valid/function/lambdas/lambdaPair.wacc
0 → 100644
View file @
b58a101a
# Take a lambda which operates on a pair
# Output:
# [addr]
# Exit:
# 0
# Program:
begin
pair(int, int){pair(int, int)} x = (\(pair(int,int) p) -> p);
pair(int, int) p = newpair(10, 2);
pair(int, int) y = call x(p);
println y
end
\ No newline at end of file
valid/function/simple_functions/lambdaHigherOrderManyVars.wacc
View file @
b58a101a
...
...
@@ -9,11 +9,12 @@
# Program:
begin
int{int} f(int{int, int, int} d) is
int{
int, int,
int} f(int{int, int, int} d) is
return d
end
int{int} x = call f(\(int x, int y, int z) -> x + y + z);
int y = call x(1,2,3);
int{int, int, int} lambda = (\(int x, int y, int z) -> x + y + z);
int{int, int, int} bar = call f(lambda);
int y = call bar(1,2,3);
println y
end
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment