Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import code in SML?

Tags:

sml

I'm currently grading assignments for a course on SML. I've written some test cases to automatically check correctness of functions in the students' assignments, and I'd like to be able to import their code and then run the test cases against that code. I'm imagining something similar to python import semantics. Right now, the best solution I have is to copy-paste this code at the bottom of each assignment. Is this possible with SML?

like image 477
jbeard4 Avatar asked Jan 30 '11 20:01

jbeard4


People also ask

How do I load an SML file?

The simplest way to load files in the SML/NJ interactive system (at the “-” prompt that you get when you run sml), is to call the use function, passing it the file name or path as a string. So to load two files we can call use twice, passing the appropriate file names. - use "wff-mod. sml"; - use "pc.

How do I run a program in SML?

To start the SML interpreter at the terminal, type "sml" and press enter. If the left/right cursor keys don't work, run "rlwrap sml" instead. Using rlwrap also provides a history; use the up/down arrows to access previously entered lines. To exit SML, press CTRL+D (or CTRL+Z under Windows).

How do I save a SML code?

Save code in simple text files with a . sml extension (if you are on a Windows machine -- the editor Textpad is fairly nice: https://www.textpad.com/ . You can download an SML syntax definition file for syntax highlighting). Then, in the REPL, type use "path/filename.


2 Answers

Use use:

use "filename.sml";
(* your test cases here *)

If you have the student solution in "student.sml" and your test cases in "tests.sml":

use "student.sml";
use "tests.sml";
like image 175
Emil Vikström Avatar answered Oct 09 '22 18:10

Emil Vikström


Look at QCheck, a unit testing library for SML

like image 26
kelloti Avatar answered Oct 09 '22 19:10

kelloti