aspose file tools*
The moose likes Functional Programming and the fly likes transation haskell to sml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Functional Programming
Bookmark "transation haskell to sml" Watch "transation haskell to sml" New topic
Author

transation haskell to sml

nikos nikosn
Greenhorn

Joined: Apr 12, 2013
Posts: 2
I have an algorithm which when we have K different sets of numbers,we have to choose a number from each set, so that the difference between the higher and the lower number is the minimum.



i want to translate this code to sml, can someone help me?
Sean Corfield
Ranch Hand

Joined: Feb 09, 2011
Posts: 267
    
    5

I can take a stab at it but first I'd like to know why you need it in Standard ML and how far you've gotten with the translation so far?
nikos nikosn
Greenhorn

Joined: Apr 12, 2013
Posts: 2
firstly, i dont know how can this "import Data.List (maximum, minimum, minimumBy)" be done in sml. i am trying to understand differences in these two languages..
Sean Corfield
Ranch Hand

Joined: Feb 09, 2011
Posts: 267
    
    5

nikos nikosn wrote:firstly, i dont know how can this "import Data.List (maximum, minimum, minimumBy)" be done in sml. i am trying to understand differences in these two languages..

I would deduce that imports the functions maximum, minimum and minimumBy from the Data.List library. Those are functions that operate on lists so maximum m will give the maximum element of the list m. From the usage of minimumBy I would deduce it is a two argument function that takes a comparator (of two arguments) and a list, and returns the minimum element according to that comparator. The rest of the code looks pretty straightforward. You should be able to deduce what $ does from the usage...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: transation haskell to sml