Last active
January 30, 2023 09:08
-
-
Save Myoga1012/21bb04c4731674956c3f to your computer and use it in GitHub Desktop.
ひらがなをランダムに生成して、5・7・5の俳句を作成するプログラムですっ!
This file contains 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
// Auther : Myoga Screw-bright | |
// Twitter : https://twitter.com/Myoga1012 | |
open System // RandomクラスとString.Joinメソッドで必要です。 | |
let rnd = Random() | |
// 0x3041(ぁ)~0x3093(ん)までのUnicodeのひらがなの句をランダムに生成します。 | |
let phrase n = [for i in 1..n -> char( rnd.Next( 0x3041, 0x3094 ) )] | |
// 5・7・5の俳句を作成して出力します。 | |
[phrase(5); phrase(7); phrase(5)] |> Seq.iter( fun phr -> String.Join( "", phr ) |> printfn "%s" ) |
This file contains 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
open System;( [5; 7; 5], Random() ) |> fun a -> a |> fst |> Seq.map( fun n -> [for i in 1..n -> char( snd(a).Next( 0x3041, 0x3094 ) )] ) |> Seq.iter( fun c -> String.Join( "", c ) |> printfn "%s" ) |
This file contains 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
open System | |
let r=Random() | |
let p n=[for i in 1..n->char(r.Next(0x3041,0x3094))] | |
[p(5);p(7);p(5)]|>Seq.iter(fun c->String.Join("",c)|>printfn"%s") | |
// 148 bytes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment