Created
July 14, 2015 09:30
-
-
Save nenono/346900b896963afdbd02 to your computer and use it in GitHub Desktop.
任意型リストのjoin(その2 by id:htid46)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let join2 (elem: 'a) (lis: 'a list) = | |
lis | |
|> List.fold (fun a x -> match a with | [] -> [ x ] | _ -> x :: elem :: a ) [] | |
|> List.rev | |
let test1 = join2 0 [1;2;3;4;5;6] = [1;0;2;0;3;0;4;0;5;0;6] // -> true | |
let test2 = join2 0 [] = [] // -> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment