• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

transation haskell to sml

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic