Questions tagged [smlnj]

Standard ML of New Jersey (SML/NJ)

SML/NJ is a popular implementation of the Standard ML programming language that was co-developed jointly by Bell Laboratories and Princeton University. It is released under a BSD like license.

References:

Wiki page

866 questions
11
votes
1 answer

Printing only print output with SML/NJ

I'm trying to use SML/NJ, and I use sml < source.sml to run the code, but it prints out too much information. For example, this is the source.sml: fun fac 0 = 1 | fac n = n * fac (n - 1) val r = fac 10 ; print(Int.toString(r)); This is the…
prosseek
  • 182,215
  • 215
  • 566
  • 871
10
votes
1 answer

Output is truncated with #-signs in the REPL

I wrote a function which works as expected but i don't understand why the output is like that. Function: datatype prop = Atom of string | Not of prop | And of prop*prop | Or of prop*prop; (* XOR = (A And Not B) OR (Not A Or B) *) local fun…
tech-ref
  • 269
  • 1
  • 2
  • 9
10
votes
3 answers

Suppress "val it" output in Standard ML

I'm writing a "script" in Standard ML (SML/NJ) that sets up the interactive environment to my liking. The last thing the script does is print out a message indicating everything went smoothly. Essentially, the last line is this: print "SML is…
Barry Brown
  • 20,233
  • 15
  • 69
  • 105
9
votes
1 answer

'How to use higher order functors properly?' or 'How to have serious fun with funsigs?'

Motivation For the life of me, I cannot figure out how to use higher order functors in SML/NJ to any practical end. According to the SML/NJ docs on the implementation's special features, it should be possible to specify one functor as an argument…
Shon
  • 3,989
  • 1
  • 22
  • 35
9
votes
1 answer

How to print variable in sml?

I'm new to SML and in debugging I usually print out the variable to see if it matches up to what I expected it should be. I would like to print out a variable within a function what i have is this : function header.. let val prod val prod = c + x…
user4348719
  • 351
  • 1
  • 2
  • 13
9
votes
2 answers

What are the options SOME and NONE in SML?

I am new to SML (and programming, actually). fun readlist (infile : string) = let val ins = TextIO.openIn infile fun loop ins = case TextIO.inputLine ins of SOME line => line :: loop ins | NONE => []…
Rohan
  • 93
  • 1
  • 1
  • 4
9
votes
8 answers

How do I install a working version of Standard ML on Mac?

I'm using Mac OSX 10.7.5 and I can't seem to get download a working Standard ML compiler with a REPL available. Is this supposed to be so difficult? Is there a best ML that I should be downloading. I've tried SML/NJ and MLton to no avail.
ordinary
  • 5,943
  • 14
  • 43
  • 60
8
votes
1 answer

Compiling SML projects from multiple files

I've got a project with many files in it and I want it to work with most popular compilers. Unfortunately, PolyML and SML/NJ require use statements, while MosML additionally requires explicitly loading basis library structures using load, which is…
zlotnleo
  • 275
  • 2
  • 12
8
votes
3 answers

Multiple Patterns in 1 case

In SML, is it possible for you to have multiple patterns in one case statement? For example, I have 4 arithmetic operators express in string, "+", "-", "*", "/" and I want to print "PLUS MINUS" of it is "+" or "-" and "MULT DIV" if it is "*" or…
rlhh
  • 893
  • 3
  • 17
  • 32
8
votes
4 answers

Remove duplicates from a list in SML

I just started learning functional programming in SML and I want to know how I can combine the following two functions into a single function. The function isolate deletes the duplicates of a list of any type ('a) using the helper function…
macalaca
  • 988
  • 1
  • 13
  • 31
8
votes
1 answer

Passing command-line arguments to an SML script

How do I go about passing command-line arguments to an SML script? I'm aware that there is a CommandLine.arguments() function of the right type (unit -> string list), but invoking the interpreter like so: $ sml script_name.sml an_argument…
abeln
  • 3,749
  • 2
  • 22
  • 31
8
votes
4 answers

How to use AND operator in IF statements in SML

I am new to SML. How do I use the AND operator inside IF statements? Here is my code: val y = 1; val x = 2; if (x = 1 AND y = 2) then print ("YES ") else print("NO "); My error is: stdIn:66.9-67.3 Error: unbound variable or constructor:…
Alexander Tilkin
  • 149
  • 1
  • 2
  • 13
7
votes
2 answers

Function which applies its argument to itself?

Consider the following SML function: fn x => x x This produces the following error (Standard ML of New Jersey v110.72): stdIn:1.9-1.12 Error: operator is not a function [circularity] operator: 'Z in expression: x x I can sort of see why…
Ismail Badawi
  • 36,054
  • 7
  • 85
  • 97
7
votes
2 answers

Typecasting in SML

I'm new to SML, and am using the SMLNJ dialect. For some purpose I have been trying to typecast 3 to 3.0 (int to real). Could not find a way out. How can I do this? How can I convert between types?
Dave
  • 391
  • 3
  • 5
  • 13
7
votes
1 answer

use operation in sml (where is current directory smlnj windows)

I have never used SML on a Windows machine (have before on a unix machine w/ emacs). for the life of me I cannot find the current directory when in the sml environment. If I attempt to: use "filename.sml" it raising an exception.. I cannot find…
DJPlayer
  • 3,244
  • 2
  • 33
  • 40
1
2
3
57 58