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

Substring.full not working in SML

I am trying to implement the full function of the Substring signature in the following way : val x = Substring.full "straight" The output returned is : val x = - : substring As I see, the function is not returning any value to the variable x. What…
Gaurav
  • 398
  • 8
  • 23
0
votes
3 answers

Just Started Learning SML: How to take two ints and return the list of all ints between

Pretty much what the title says. I just started learning SML and am having trouble with my first project. I understand this is a very basic question and it would be incredibly easy for me to do in something like java, but I'm having difficulty…
Jonerhan
  • 97
  • 1
  • 11
0
votes
1 answer

Binary Search Tree in SML

I am trying to implement a Binary Search Tree in SML. I have an insert function and I am trying to implement another function that takes a list and calls the insert function on each element in the list. This is what I have so far, fun insertB (l) =…
0
votes
1 answer

Making an integer value from a list that represents that integer

Hello i am attempting to write a function in SML. My goal is to create a function which takes a list that represents a value such as [2,3,4] and would return its integer representation i.e 432 (in the list the first element is the ones place). so…
user4348719
  • 351
  • 1
  • 2
  • 13
0
votes
1 answer

Why is this SML function returning a syntax error?

fun first_answer(my_f:('a -> 'b option)) : 'a list -> 'b = let fun help(_a:'a list) : 'a = (((List.map valOf)o(List.filter isSome)o(List.map my_f)) _a) in help end; Error: syntax error: replacing WILD with SEMICOLON Something with that _a is…
IamPolaris
  • 1,021
  • 2
  • 10
  • 19
0
votes
1 answer

SMLNJ - error: operator domain ?.C list operand C list

I have this code in SMLNJ: val reduce = fn : C list -> C list * int datatype C = R | G | B | Y | SR | SG | SB | SY | DR | DG | DB | DY | P | W | W'; fun exhaustiveReduce(cList)= let fun helper((cList, score), prevScore, flag)= …
user265732
  • 585
  • 4
  • 14
0
votes
1 answer

Unbound variable or constructor

I'm having trouble defineing a curried function with let,in,end. I have the following code: filter_many listOfFunc listOfElements = let fun allPredicate(element,[]) = true | allPredicate(element,(a,b)::xs) = a(element) andalso…
0
votes
1 answer

How to easily shuffle a list in sml?

How can I easily shuffle a list of tuples in sml? There doesn't seem to be any built in function to do so. I assume I would need to use a random number generator but how you would move items in an list I have no idea.
0
votes
1 answer

Implementing next_permutation in sml?

How would I implement this in SML? Is it possible to change the inner for-loop to a recursive inner function? void RecursivePermute(char str[], int k) { int j; // Base-case: All fixed, so print str. if (k == strlen(str)) printf("%s\n",…
0
votes
1 answer

SML finding a sum of squares/halves using other functions

So I want to find the sum of applying function f to the first n integers, when the sum of applying f to the first n integers is f applied to n plus the sum of applying f to the first n-1 integers, as in: - fun inc x = x+1; > val inc = fn : inet ->…
0
votes
1 answer

"deleteAll" method only removes one occurrence

I've been asked to write a Standard ML Program which deletes every occurrence of a list from another list. For the life of me I cannot understand what is wrong with my code. Any help would be appreciated! My input for this program is as…
0
votes
1 answer

SML: How to separate a list into a tuple of 2 lists?

So, I am trying to solve this question which says, write a function to take the next word off a list of characters. The function returns a tuple of the word as a list of characters and the rest of the list. e.g. next [#”t”,#”h”,#”e”,#”…
Balraj Singh Bains
  • 1,312
  • 1
  • 9
  • 8
0
votes
0 answers

SML : Dequeue a list of tuples

I have a datatype of the form : datatype 'a mlqueue = N | Q of (int * int * 'a) list; I have to write a dequeue function such that val dequeue : 'a mlqueue -> 'a * 'a mlqueue* So if my queue is : val q = Q…
na899
  • 163
  • 1
  • 2
  • 9
0
votes
2 answers

Moving elements in a priority queue to a lower level

I have a multi-level priority queue which is implemented as a list of (level:int, priority:int, 'a). The datatype looks like this: datatype 'a queue = NONE | Q of (int * int * 'a) list; Elements at lower level are at the front of the queue.…
na899
  • 163
  • 1
  • 2
  • 9
0
votes
1 answer

My sml compiler doesnot recognize simple operations on arrays (update(arr,int,int), array(int,int) etc). Help!

I installed the sml interpreter from here : http://www.smlnj.org/, I used the self extracting .EXE for windows. (I'm running windows7 64 bit) Although simple operations on basic datatypes are working, it is not recognising operations on…
shubh
  • 1
  • 1