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
5
votes
3 answers

Is it possible to create a "generic" function in Standard ML?

I would like to create a function remove_duplicates that takes a list of any type (e.g. can be an int list or a bool list or a int list list or a whatever list) and returns the same list without duplicates, is this possible in Standard ML?
user11719516
5
votes
0 answers

Practical applications of and recent progress on "Efficient and Safe-for-Space Closure Conversion" by Appel and Shao

When compiling a functional program to machine language, the compiler has to choose how to implement closures. In the following example (Scheme syntax), the function f returns the procedure (lambda (y) (+ x y)) whose machine representation (its…
Marc
  • 4,327
  • 4
  • 30
  • 46
5
votes
2 answers

Capturing stdout of a command in SML

I'm trying to capture the output of a command run using Posix.Process.execp. I ported some C code I found on stackoverflow and can capture output for one execution, but I can't get the output for a second execution. Here's my function: (* Runs a…
Ryan Kavanagh
  • 251
  • 1
  • 7
5
votes
1 answer

catching exceptions in ML

is it possible in ML catch every possible exception? for example if I don't know what exception might be
rookie
  • 7,723
  • 15
  • 49
  • 59
5
votes
1 answer

How to install smlnj in arch linux?

Earlier I was in Ubuntu & it was easy to install smlnj using apt-get install smlnj but now I shifted to Arch & I'm finding it difficult to install smlnj. I tried to find smlnj package through yaourt but I didn't found any. Then I tried to install…
LearningGiraffe
  • 145
  • 3
  • 11
5
votes
2 answers

Horner's rule for two-variable polynomial

Horner's rule is used to simplify the process of evaluating a polynomial at specific variable values. https://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation#Standard_ML I've easily applied the method using SML, to a one variable…
5
votes
1 answer

Why can't I compare reals in Standard ML?

Why doesn't 1.0 = 2.0 work? Isn't real an equality type? It gives the error: Error: operator and operand don't agree [equality type required] operator domain: ''Z * ''Z operand: real * real in expression: 1.0 = 2.0 Why won't…
sshine
  • 15,635
  • 1
  • 41
  • 66
5
votes
1 answer

Standard ML fibonacci overflow

I've been messing around with learning some functional programming and decided to pick up ML as my vehicle to do so. It's only been a few days since I picked up ML and maybe have spent about 5-6 hours total working through some problems. Anyway, on…
Matt Matero
  • 119
  • 1
  • 10
5
votes
1 answer

SML/NJ using CM.make: "Error: illegal character"

I'm trying to compile the following program from Shipman's Unix System Programming with Standard ML: structure Main= struct fun main(arg0, argv) = ( case argv of [] => () | (first::rest) => ( …
gotchops
  • 53
  • 4
5
votes
3 answers

How to convert String to int(and not to int option) in SML

I am trying to extract integer value from a string using Int.fromString function but as we know, its specification is : String -> int option. So the result of applying Int.fromString is of type int option. But I need the result of type int. Also I…
Ankit Shubham
  • 2,989
  • 2
  • 36
  • 61
5
votes
1 answer

How to do bitwise AND in SML/NJ?

Need it for a program I'm writing (repeated squaring to comput x^n). I can't seem to find the syntax for it, or if it is even supported.
David Crosby
  • 175
  • 7
5
votes
1 answer

Resolve library conflict in SML/NJ Compilation Manager

I'm using SML/NJ 110.79, which includes support for new structures defined by the Successor ML project. Among others, the Fn structure. As it happens, I already had an identically named structure in one of my personal project with utilities, which…
Ionuț G. Stan
  • 176,118
  • 18
  • 189
  • 202
5
votes
1 answer

Resolving module name conflicts, need to get at ORD_MAP signature

I'm working on a relatively large SML codebase. It was originally written to compile with MLton, but I'm now working with it under SML/NJ. I need to use RedBlackMapFn, which is defined in smlnj-lib.cm. However, I get an…
Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
5
votes
2 answers

What does val it = () : unit mean in SML?

I've never programmed in SML before, and I'm using SML/NJ. It keeps giving me the following at the end of each program I run: val it = () : unit What does this mean? Is it something I'm doing wrong?
Horse SMith
  • 1,003
  • 2
  • 12
  • 25
5
votes
1 answer

Trouble with Curry functions (SML/NJ)

Often we are interested in computing f(i) i=m n∑ , the sum of function values f(i) for i = m through n. Define ‘sigma f m n’ which computes f(i) i=m n∑ . This is different from defining ‘sigma (f, m, n)’ I'm required to write a Curried version…
user2796815
  • 465
  • 2
  • 11
  • 18