ml

CGI site , moscow ml problem

Hello , i'm using Moscow ML combined with CGI. I have a site that calculates simple arithmetics. When the submit button i pushed, the site is redirected to the actual CGI file that outputs the result of the calculation. Although in my case, it outputs the html code in raw form rather then actually outputting the result in html. Anybody t...

Explain ML type inference to a C++ programmer

How does ML perform the type inference in the following function definition: let add a b = a + b Is it like C++ templates where no type-checking is performed until the point of template instantiation after which if the type supports the necessary operations, the function works or else a compilation error is thrown ? i.e. for example,...

Deriving type expression in ML

All, I want to derive the type expression for the function below in ML: fun f x y z = y (x z) Now I know typing the same would generate the type expression. But I wish to derive these values by hand. Also, please mention the general steps to follow when deriving type expressions. ...

Standard ML: Return different types

I need to return a different value based on the function passed into another function. So, given: fun inc x = x + 1; And: fun double [] = [] | double (h::t) = 2*h::double (t); You should be able to call the function I'm working on with either. Example call (the function I'm making is named test): test (inc, 5); - And it would return...

How to create a function in ML using a Recursive Datatype

Given the datatypes: datatype bunch = One of int | Group of bunch list; datatype 'ex bunch = NIL | One of 'ex | Group of 'ex * 'ex bunch; How can I design a function to, for example, return the sum of this recursive function. I understand how to define a recursive function and slig...

Access guarantees of ML Refs?

Are there any access guarantees with ML's Ref type in the face of concurrent access? ...

Using Hadoop map/reduce for programming language design course project

I need to design an exercise for my students in programming language design, My idea is help them to learn ideas in lisp, ML and other functional languages by force them to implement a mapreduce exercise with hadoop. Is here any suggestion that help me detail my idea? ...

ML Expression, help line by line

val y=2; fun f(x) = x*y; fun g(h) = let val y=5 in 3+h(y) end; let val y=3 in g(f) end; I'm looking for a line by line explanation. I'm new to ML and trying to decipher some online code. Also, a description of the "let/in" commands would be very helpful. ...

Standard ML (using MoscowML) Whats wrong with this function? (filter)

This is part of a homework assignment so my goal is to understand why this is wrong. As I mentioned before I'm using Moscow ML. fun filter pred = let fun f ([], a) = [] | f ([], a) = a | f (e::L, a) = if pred e then (f L (e::a) ) else (f L a) in f end The error I get is: | f (e::L, a) = if pred e then (f L (e::a) ) else (f L a...