Sort by

recency

|

189 Discussions

|

  • + 0 comments
    open System;
    
    let n = Console.ReadLine () |> int
    
    let rec read arr =
        match Console.ReadLine () with
        | x when String.IsNullOrEmpty x -> arr
        | x -> x :: arr |> read
    
    read []
    |> List.rev
    |> List.collect (fun x -> List.replicate n x)
    |> Seq.iter (fun x -> printfn "%s" x)
    
  • + 0 comments
    f :: Int -> [Int] -> [Int]
    f n [] = []
    f n (x:xs) =  (helper (n) (x:xs)) ++ f (n) xs
        where helper n (x:xs)   | n==0 = []
                                | otherwise = x:helper (n-1) (x:xs)       
    

    Haskell beginner here

  • + 0 comments

    Scala, such that I am new to Scala and functional programming

    def getNumElements(s: Int, element: Int, result: List[Int]): List[Int] = {
        if (s > 0) {
            getNumElements(s - 1, element, result :+ element)
        } else {
            result
        }
    }
    
    def f(num: Int, arr: List[Int], result: List[Int] = List(),
          repeater: (Int, Int, List[Int]) => List[Int] = getNumElements
         ): List[Int] = {
        if (arr.size > 0) {
            f(num, arr.tail, result ::: repeater(num, arr.head, List()))
        } else {
            result
        }
    }
    
  • + 0 comments

    Functional progremming is very usefull for my website wishesbeast which is relate to online gaming and a lot of other topics. Experience the passion, excitement, and camaraderie of being part of a global Liverpool FC fanbase. Visit our website and immerse yourself in the heart of the action

  • + 2 comments

    Scala resolution

    def f(num: Int, arr: List[Int]): List[Int] = arr.flatMap(x => for (i <- 1 to num) yield x)