-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Currying functions quiz * Add comment re: param pattern
- Loading branch information
1 parent
c8bbfb5
commit a3e7baf
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ install-smlsharp | |
links.md | ||
**/*temp.md | ||
todo.md | ||
temp* | ||
|
||
# Logs | ||
logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
fun foo l = map real l; | ||
foo [1,2,3]; | ||
|
||
fun foo l = foldr (fn (e, li) => e::e::li) [] l; | ||
foo [1,2,3]; | ||
|
||
fun foo p l = foldr (fn (e, (lt, gt)) => if e <= p then (e::lt,gt) else (lt,e::gt)) ([],[]) l; | ||
foo 3 [1,2,3,4,5]; | ||
|
||
fun cubelist li = map (fn(cur) => cur*cur*cur) li; | ||
cubelist [1,2,3]; | ||
|
||
fun removeAll li x = foldr (fn (cur, acc) => if cur = x then acc else cur::acc) [] li; | ||
removeAll [1,2,3,4,5,6,7,8,9,10] 5; | ||
|
||
(* You can rearrange the order of the params like this *) | ||
fun removeAll x li = foldr (fn (cur, acc) => if cur = x then acc else cur::acc) [] li; | ||
|
||
(* But then the call site must be updated to reflect the new order *) | ||
removeAll 0 [1,2,0,3,4,0,5]; |