Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
fun isBalanced s = checkBrackets 0 (String.explode s)
|
||||
and checkBrackets 0 [] = true
|
||||
| checkBrackets _ [] = false
|
||||
| checkBrackets ~1 _ = false
|
||||
| checkBrackets counter (#"["::rest) = checkBrackets (counter + 1) rest
|
||||
| checkBrackets counter (#"]"::rest) = checkBrackets (counter - 1) rest
|
||||
| checkBrackets counter (_::rest) = checkBrackets counter rest
|
||||
11
Task/Balanced-brackets/Standard-ML/balanced-brackets-2.ml
Normal file
11
Task/Balanced-brackets/Standard-ML/balanced-brackets-2.ml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
val () =
|
||||
List.app print
|
||||
(List.map
|
||||
(* Turn `true' and `false' to `OK' and `NOT OK' respectively *)
|
||||
(fn s => if isBalanced s
|
||||
then s ^ "\t\tOK\n"
|
||||
else s ^ "\t\tNOT OK\n"
|
||||
)
|
||||
(* A set of strings to test *)
|
||||
["", "[]", "[][]", "[[][]]", "][", "][][", "[]][[]"]
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue