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

CML code not giving output

How to view the output of following code? fun daughter () = let val daughter_tid = getTid(); in print ("DAUGHTER : my tid = " ^ (tidToString daughter_tid) ^ "\n") end; fun mother () = let …
Amber
  • 1,229
  • 9
  • 29
0
votes
1 answer

Generate natural numbers and printing them using 2 communication servers in Concurrent ML

I have a homework where i need to write 2 communication servers, one which generates natural numbers and the other which prints them. the generating server will be sending to the printing server. The servers should communicate over the shared…
user2948246
0
votes
2 answers

Working With Units in ML (SML/NJ)

I am trying to make a function that will print binary trees. My binary tree datatype looks like this: datatype 'a BT = empty | bTree of 'a * 'a BT * 'a BT; I have also made a function that prints integers, which I will be using for the nodes: …
user2803198
  • 57
  • 1
  • 2
  • 6
0
votes
2 answers

Standard ML syntax error: illegal token on hello world program -- incorrect SML installation?

The SML file: "test.sml" (* here is a comment *) val x = 123; I've installed SMLNJ 110.76 from here: http://www.smlnj.org/dist/working/110.76/, Emacs 24.3.1 from here: http://ftp.gnu.org/gnu/emacs/windows/emacs-24.3-bin-i386.zip, and SML Mode for…
user941238
  • 640
  • 1
  • 8
  • 19
0
votes
1 answer

copying files in sml

I am trying to learn input output in sml.In an effort to copy strings of lsthat are the same as s1 into the file l2 I did the following.I am getting some errors I can not really understand.Can someone help me out. fun test(l2:string,ls:string…
Emma
  • 323
  • 3
  • 16
0
votes
1 answer

SML: declear but not define function

This is just an example. These two functions are connected. You really want to call the one called lowest. It should then return the lowest number of the two. This of course won't work because you at the time of compiling the reducemax function you…
Horse SMith
  • 1,003
  • 2
  • 12
  • 25
0
votes
2 answers

Overwriting an element in an sml list

I'd declared the function below in the hope that if I am to overwrite some element in the list it actually works.But I am not completely sure if this is the right way.Any ideas different than mine will be appreciated fun foo (ls,n) =if ls = nil…
Emma
  • 323
  • 3
  • 16
0
votes
1 answer

Bijective function in sml

I would like to define a function that takes an integer n and returns an integer n* such that n and n* are in the same set of integers from 1 to n,and the function must be bijective. I tried the following fun bij(n) = let val ls =…
Emma
  • 323
  • 3
  • 16
0
votes
1 answer

right-hand-side of clause doesn't agree with function result type [literal]

I am trying to compute binomial coefficients using Dynamic Programming. I keep getting this error fun binomial(m:int, n:int, DP) = if n = m orelse n = 0 then Array2.update(DP, m, n, 1) else if Array2.sub(DP, m, n) = ~1 then ( if…
user645332
  • 15
  • 1
  • 1
  • 3
0
votes
1 answer

code logical error in SML

I'm using the below code for square root from a cornell course, however the code returns wrong values, The code is fun squareRoot(x: real): real = let val delta = 0.0001 fun goodEnough(guess: real): bool = if(abs(guess*guess - x) <…
user2433145
  • 32
  • 2
  • 8
0
votes
1 answer

Is is possible to read in a list of numbers in SML?

I'm trying to make a program in SML that will read in a series/list/sequence of numbers from the user, process the numbers, and output the result. I don't know how many numbers the user will input. The program can either read in all the numbers and…
Jed Schaaf
  • 1,045
  • 1
  • 10
  • 19
0
votes
1 answer

is zip function in the standard sml basis library?

I am trying to implement a function that creates a list from two int lists to form pairs. But when I try to run zip, it tells me that this is an unbound variable. Is there any other function which does the same job in the library or some definition…
Emma
  • 323
  • 3
  • 16
0
votes
2 answers

How to run .sml file by using emacs?

I'm not able to run simple .sml file in emacs. Please, help me. Standard ML of New Jersey v110.76 [built: Sun Jul 14 09:59:19 2013] - use "s.sml" ; [opening s.sml] [use failed: Io: openIn failed on "s.sml", Win32TextPrimIO:openRd: failed] uncaught…
user1494990
  • 11
  • 1
  • 3
0
votes
1 answer

Using foldr to simplify a function (SML / NJ)

I have this function fun exist p M = foldr( fn(x,y) => x orelse y ) false (map p M) I need to write it using only the foldr function, but can only call foldr once. I'm confused on how I should handle this. Do i need to revise my anon function?
user2796815
  • 465
  • 2
  • 11
  • 18
0
votes
1 answer

Applying x to a list of functions (SML)

I'm trying to create a function myMap that applies x to a list of functions using map. Example: myMap [f1, f2, ..., fn] x ==> [f1(x), f2(x), ..., fn(x)] I believe I need to write an anonymous function to complete this task, but am having trouble…