File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transation haskell to sml

 
nikos nikosn
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
9
Clojure Linux Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
9
Clojure Linux Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic