.. (לתיקייה המכילה) | ||
How can we print in ML? | |
You can print string values: val non = print "Hello World\n"; The constant non is not used. It's declaration has a side effect of printing to command prompt. Conversing int to string and printing: val non = print ((Int.toString 15) ^ "\n"); You can do the same using: Bool.toString and Real.toString Printing an argument: fun foo 0 = 0 | foo x = let val non = print ((Int.toString x)^ " "); in x + foo (x-1) end; Conversing int list to string: fun intListToString [] = "" | intListToString (x::xs) = (Int.toString x) ^ " , " ^(intListToString xs); Conversing int list list to string: (might be useful for printing the board) fun intListListToString [] = "" | intListListToString (x::xs) = (intListToString x) ^ " | " ^ (intListListToString xs); Don't forget to remove prints before submission! |
When we call some of our functions with Nil as a parameter, we receive a message like: "stdIn:7.1-7.9 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) val it = Nil : ?.X1 seq". Is this ok? | |
ML gives you this warning when you call a polymorphic function with a polymorphic parameter. You can read more about this at the end of tutorial 1. For assignments in this course, you may ignore these warnings. |
Standard ML - May we ignore "Warning: calling polyEqual" warnings? | |
Yes. This warning doesn't indicate any real problem with the code. You can also try turning these warnings off with the command: "Control.polyEqWarn := false" |
I am getting the character # in some of ML's replies to my declarations, and the declared values seem to be too short. Is this OK? | |
Yes it is (generally). The # char is ML saying `etc etc'. You can make ML type out fully the declared value by using this command at the beginning of your session: - 'Compiler.Control.Print.printDepth := 1000;' (or 'Control.Print.printDepth := 1000;') An alternative solution for ML: Compiler.Control.Print.stringDepth := 1000; (or Control.Print.stringDepth := 1000;) |