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

SOME([]) interpreted as 'z -> 'z option rather then 'z list option

Hi im trying to write a simple function using the standard library it should take the following argument try = fn: 'a -> 'b list option a_list = 'a list and the defintion is the following: fun all_answers try a_list = let fun acc(SOME(a),…
user25470
  • 585
  • 4
  • 17
0
votes
2 answers

How to shorten a list in standard ml

I just start working with standard ml and really have some trouble understanding the list in this language. So my question is how to shorten a list in ml ? For example, if I have a list [1,2,3,4,5,6], I want to shorten it to [1,2]. What I'm having…
user4075830
  • 87
  • 1
  • 2
  • 11
0
votes
2 answers

Change a variable in standard ml list

I wonder when working with list in ml, how to change a variable with specific location of the list. For instance, when I have a list [1,2,3,4], I want to change the list to [1,2,5,4] with the 5 subtitle for the 3. What i'm thinking is to write a…
user4075830
  • 87
  • 1
  • 2
  • 11
0
votes
2 answers

How to calculate indegree and outdegree for a graph in directed graph SML code?

I have a tuple like (1,2),(3,4),(4,5). Edges: 1->2, 3->4 and so on. How calculate in degree and out degree for each vertex?
offeron
  • 157
  • 2
  • 2
  • 10
0
votes
2 answers

Differentiate between atom and list in SML

I am new to SML programming and I have a problem to create a function to remove occurrences of an atom A from a list of integers. This list can be nested to any levels, means we can have list like [1,2,3] and we can have list like [[1,2],[2,3]] as…
0
votes
1 answer

2D Binary Tree in SML

I am having a difficult time figuring out how to implement a 2d binary tree using sml This is what I have so far but I get a tycon mismatch. datatype btree = Empty | Node of int * btree * btree; fun AddNode…
0
votes
2 answers

Checking for matching parenthesis

I am trying to write a code such that, given a list of parenthesis, I will check if the order is valid or not. For simpleness, the follwoing datatype is defined. datatype par = LPAR | RPAR type pList = par list What I have until now is: fun…
Sarah cartenz
  • 1,313
  • 2
  • 14
  • 37
0
votes
2 answers

NLFFI: wrong values are sent to C function arguments of type "short"

It seems like a bug in NLFFI SML/NJ implementation. C function is void f0 ( short a0 , short a1 and so on , short a7 ) { printf ("a0 == %hx\n", a0); printf ("a1 == %hx\n", a1); and so on printf ("a7 == %hx\n", a7); } I…
beroal
  • 369
  • 4
  • 14
0
votes
1 answer

Datatype for Dijkstra's algorithm?

I'd like to turn a 2D array (having nodes but also obstacles) into a graph in order to run Dijkstra's algorithm in SML, but as a beginner I don't come up with a good idea about the datatype I should use. Any help is welcome, thanks.
luthien
  • 1,285
  • 3
  • 15
  • 26
0
votes
1 answer

SML/NJ Read next character from file ignoring whitespace

Can you give me a solution to create a function that reads the next character in a file stream, ignoring whitespace? (in SML/NJ).
Noob Doob
  • 1,757
  • 3
  • 19
  • 27
0
votes
1 answer

Function binding and function call evaluation

I have a little trouble understanding the evaluation of function bindings and function calls in SML. A simple example of a function binding and a function call: val w = 12; fun pow(x:int,n:int) = if n = 0 then 1 else x *…
TheAptKid
  • 1,559
  • 3
  • 25
  • 47
0
votes
1 answer

Evaluate or execute a string in sml

I'm looking for a way to execute as string in sml. For example: val evalResult = eval "1 + 1"; > val it = 2 : int I can't actual believe that I didn't find any resource on this topic... Any help is appreciated.
scheffield
  • 6,618
  • 2
  • 30
  • 31
0
votes
1 answer

How do I open and run ML Lex on Windows 7?

I downloaded the SMLNJ installer for Windows and ran it. This has created a shortcut to SML of New Jersey which I can use as an ML interpreter. This installer is also supposed to have installed ML Lex, but I have absolutely no idea about how to run…
James Wright
  • 119
  • 1
  • 3
0
votes
1 answer

What's "node" doing in this snippet of SML?

I'm working on a project that has a lot code that looks like this: structure MyStruct = struct datatype node = A of Foo.t | B type t = node Wrap.t fun layout myNode = case node myNode of A foo => Foo.bar foo | B => "void" end Wrap is…
Patrick Collins
  • 10,306
  • 5
  • 30
  • 69
0
votes
1 answer

Trying to understand the Lex syntax for Standard ML (ml-lex)

I'm writing a compiler. I'm at the first phase, trying to tokenize everything. I wrote it all up, but I get an error. I've read the docs (smlnj) three or four times, and the errors are not very informative. I think I must be messing up the state…
robins35
  • 653
  • 12
  • 37