We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Functional Programming
  3. Introduction
  4. Update List
  5. Discussions

Update List

Problem
Submissions
Leaderboard
Discussions

Sort 80 Discussions, By:

votes

Please Login in order to post a comment

  • gmrodgers
    6 years ago+ 1 comment

    f arr = map abs arr

    7|
    Permalink
  • patrickwherrmann
    4 years ago+ 1 comment

    Here's kind of a funny solution:

    main = interact $ filter (/= '-')
    
    6|
    Permalink
  • PaGrom
    5 years ago+ 0 comments

    Clojure:

    (fn[lst]
        (map #(Math/abs %) lst))
    
    5|
    Permalink
  • balintant
    6 years ago+ 0 comments

    Haskell

    -- Enter your code here. Read input from STDIN. Print output to STDOUT
    
    f arr = [abs x | x <- arr]-- Complete this function here
    
    -- This section handles the Input/Output and can be used as it is. Do not modify it.
    main = do
       inputdata <- getContents
       mapM_ putStrLn $ map show $ f $ map (read :: String -> Int) $ lines inputdata
    
    3|
    Permalink
  • johanirvall
    4 years ago+ 0 comments

    Full solution including IO-handling in F#:

    Seq.initInfinite (fun _->System.Console.ReadLine())
    |> Seq.takeWhile ((<>) null)
    |> Seq.map (int>>abs)
    |> Seq.iter(printfn "%d")
    
    1|
    Permalink
Load more conversations

Need Help?


View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature