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
0
votes
1 answer

Behavior of function with anonymous function in it

Being new to SML, using SML NJ I recognized this behavior of a function: - fun test g= fn x=>x; val test : 'a -> 'b -> 'b = _fn - test 1 2; val it : int = 2 - test 1; val it : '1 -> '1 = _fn Is it so, that the interpreter uses unit as datatype for…
Sebastian Walla
  • 1,104
  • 1
  • 9
  • 23
0
votes
1 answer

datatype for list operation

I have this problem to solve and I have managed to solve it but without that function execute_ops. This is my solution: datatype list_op = insert of int*int | delete of int | setsize of int; exception wrong_case; fun insert(x,pos,nil) = [x] |…
zeeks
  • 775
  • 2
  • 12
  • 30
0
votes
1 answer

Unable to find $ml-yacc-lib.cm

I try to installed a software written in Standard ML of New Jersey (SML/NJ). I don't know at all this language, but logically, I just install SML/NJ on my machine with the following command : sudo apt-get install smlnj Then the author of the…
Valentin Montmirail
  • 2,594
  • 1
  • 25
  • 53
0
votes
1 answer

Generating cartesian power in Standard ML

The common cartesian product can be implemented as: fun cartesian(xs, ys) = let fun pairOne(x,[]) = [] | pairOne(x, y::ys) = [x,y]::pairOne(x,ys) fun cart([],ys) = [] | cart(x::xs, ys) = pairOne(x, ys) @ cart(xs,ys) in …
Jimmy C
  • 9,270
  • 11
  • 44
  • 64
0
votes
1 answer

Understanding sum function calling itself (recursion?) - SML

I've been trying to learn SML NJ (standard ML New Jersey) and I've come across a function that I understand to be recursion, but can't quite figure out why the function returns the value that it does. Function: fun sum 0 = 0 | sum n = n+sum…
Chris
  • 785
  • 10
  • 24
0
votes
1 answer

Function only deletes one of many occurrences of a list

I'm writing a function that uses one list as an occurrence. The function then takes this list and removes all occurrences of it from another list. For example: [1,2,3] should be removed from [3,2,1,2,3,1,2,3] giving us [3,2] [1,2,3] should not be…
madcrazydrumma
  • 1,847
  • 3
  • 20
  • 38
0
votes
1 answer

A currying function

I have: - fun F p q = p q; val F = fn : ('a -> 'b) -> 'a -> 'b I know how to use it, for example by first having fun square x = x*x and then invoking F Sq 3. However, I don't quite understand the function expression in the second line. Can…
Old Geezer
  • 14,854
  • 31
  • 111
  • 198
0
votes
1 answer

SML List Deletion

I am trying to write a function to delete a list from another list. ''a list -> ''a list -> ''a list Here's what I have so far: fun delete _ [] = [] | delete (h1::t1) (h2::t2) = if h1=h2 then t2 else h2::delete (h1::t1)…
Arjun
  • 817
  • 3
  • 16
  • 28
0
votes
1 answer

Getting a match redundant error when trying to access the tail of a list

I'm writing a function in sml which checks if an initial list is contained within any aspect of the second list. Here is what I have so far: fun contains l1 [] = false | contains l1 (hd::tl) = contains l1 tl | contains l1 l2 = starts l1…
madcrazydrumma
  • 1,847
  • 3
  • 20
  • 38
0
votes
2 answers

Checking if a char is a digit

As part of a practice SML exam I was asked to write a function that checks if a character 'c' is a digit or not. I was looking into the Char.ord function but it returns the ASCII code and not the integer itself in the character, and I can't seem to…
madcrazydrumma
  • 1,847
  • 3
  • 20
  • 38
0
votes
1 answer

Why does #i to get elements in tuples work on command line but not program?

I'm just starting to learn SML. I want to write a function get the second element out of a tuple. Seems simple enough since on the command line I can say val a = (1, 2, 3); #2 a; So how come this function... fun second(x) = #2 x; throws this…
Nick Gilbert
  • 4,159
  • 8
  • 43
  • 90
0
votes
1 answer

SML/NJ windows installer

Can anyone verify that the .msi works on Windows 10? I have been downloading and trying different versions 110.75 - 78 with no success. The installers will all start up but after you choose the install directory and hit install the following…
Neck Beard
  • 383
  • 5
  • 8
0
votes
1 answer

SMLNJ REPL error "!* unable to process ..."

I am using SML NJ v110.78 on Mac OS X 10.9. I am trying to use command-line arguments from BASH, like so: sml progname.sml 2.0 1.0. The program progname.sml compiles and runs and uses the command-line arguments to produce a value (using…
Pinecone
  • 391
  • 4
  • 9
0
votes
1 answer

Trouble Installing Standard ML

So I'm trying to install Standard ML/NJ on a Mac running Yosemite. I download the installer for Mac OS X PPC and try to install. I get an error saying "The installation failed. The installer encountered an error that caused the installation to…
anon_swe
  • 8,791
  • 24
  • 85
  • 145
0
votes
1 answer

SML specification for IntListSet structure

val x = IntListSet.listItems(IntListSet.addList(IntListSet.empty,[1,2,3,4,5,6])); If you run this in SML, it returns x = [1,2,3,4,5,6] : IntListSet.item list I want it to return x = [1,2,3,4,5,6] : Int list What should I do?
ysig
  • 447
  • 4
  • 18