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

How can we denote list of tuples in argument

In sml, we define lists of integers or strings as arguments by l::ls which helps us to define lists of arbitrary length and then we can compare with = or > or <. How can we denote tuples in similar manner? e.g. I can write, fun delete(x,l::ls)=if…
700resu
  • 259
  • 6
  • 16
0
votes
1 answer

Why is there type mismatch of operator and operand?

Why is there a tycon mismatch operator and operand do not agree error? Any Suggestion for a solution? fun reve (x:string) = implode o rev o explode x
700resu
  • 259
  • 6
  • 16
0
votes
1 answer

How do I define my own mymod function?

I am trying to define my own mymod function where mod is usual 3 mod 2 =1 function. I dont know where to start. Any Suggestion?
700resu
  • 259
  • 6
  • 16
0
votes
1 answer

Why does the following function not end?

Why does the following function not end? (* funct1 is a different function that does end *) fun funct(a,b::bs)=let val c=a in funct1(c,a,b::bs); = ; = ; = ; = ; stdIn:15.54-17.2 Error: syntax error: deleting SEMICOLON SEMICOLON SEMICOLON
700resu
  • 259
  • 6
  • 16
0
votes
1 answer

Check whether an input is real of integer

I want to ask the user to input a variable and check it is real or integer and take two different operations for corresponding actions. Say true if integer else false; fun realorinteger(n)= if n=int then true else false; but it definitely does not…
700resu
  • 259
  • 6
  • 16
0
votes
1 answer

SML Value Restriction - Heap

Basically, I want a function to make a heap from a node and 2 subheaps. The heap representation is as follows (where the int in the Cons represents the rank of the node) datatype 'a heap = Empty | Heap of int * 'a * 'a heap * 'a heap and my…
Mouhyi
  • 277
  • 2
  • 11
0
votes
1 answer

Runtime error in sml function

I am writing this function in sml fun removeNodeswithNoIncoming((x:int,y)::xs,element:int) = if x=element then removeNodeswithNoIncoming (xs , element) else (x,y) :: removeNodeswithNoIncoming (xs , element) | removeNodeswithNoIncoming(nil,element)…
Rpant
  • 974
  • 2
  • 14
  • 37
0
votes
1 answer

simple function to return list of integers

if am trying to write a simple function that list of pair of integers - representing a graph and returns a list of integers : all the nodes in a graph eg if input is [(1,2) (3,4) (5,6) (1,5)] o/p should be [1,2,3,4,5,6,1,5] The function is simply…
Rpant
  • 974
  • 2
  • 14
  • 37
0
votes
1 answer

Addition in SML using pattern matching

I'm learning sml for the first time and I'm not too sure about the syntax for pattern matching. As practice, I've tried to make some simple programs about binary numbers. datatype Digit = Zero | One type Nat = Digit list fun inc [] = One::[] | inc…
John Smith
  • 635
  • 1
  • 10
  • 19
0
votes
2 answers

SML method that accepts a list list and returns a list

I need to create a method that takes a list of lists (like [ [2,3,] , [4,5] ]) and returns something like [2,3,4,5]. I can work out the logic but I dont know how to define the method in SML. I tried this but it does not compile fun…
Katianie
  • 589
  • 1
  • 9
  • 38
0
votes
2 answers

concurrent ml how import library

I have downloaded Standard ML of New Jersey (SML/NJ) and now I have to use the library of concurrent Ml (CML). How can I import (use) the library? Thanks
0
votes
1 answer

right-hand-side of clause doesn't agree with funct result sml

fun can_move 0 0 0 nil = false | can_move limit_down V 0 a = true | can_move limit_down V count a = if ((V-limit_down)>hd a) then false else can_move limit_down V (count-1) tl a ; Hey this my code I just want to check…
MikEKOU
  • 41
  • 1
  • 6
-1
votes
1 answer

SML Uncaught Exception Empty

I am quite new to SML and am trying to implement a selection sort. I am running into an uncaught empty error however and can't seem to see why. fun removeMin lst = let val (m, l) = removeMin(tl lst) in if null (tl lst) then (hd…
-1
votes
1 answer

how to iterate over a list using one liner msl?

i have a list , and a tuple (start,end,interval) i am trying to iterate over the list and return the elements that are in list from start to end with interval steps . for example: cutt [1,2,3,4,77,8,7] (1,5,2); val it = [2,4,8] : int list; the…
memeeol
  • 35
  • 7
-1
votes
2 answers

smlnj listdir problems

I am a newbie learning sml and the question I am given involves IO functions that I do not understand. Here are the 2 questions that I really need help with to get me started, please provide me with code and some explanation, I will be able to use…
czy1985