Last active
January 30, 2023 09:09
-
-
Save Nia-TN1012/13e3e7117b95f46d181906b1281aab97 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 : Nia Tomonaka | |
// Twitter : https://twitter.com/nia_tn1012 | |
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" ) | |
// Haiku.fs | |
// Copyright (c) 2014-2023 Nia T.N. Tech Lab. / Chronoir.net. | |
// This software is released under the MIT License. | |
// http://opensource.org/licenses/mit-license.php |
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
GitHubのアカウント統合のため、Myoga1012→Nia-TN1012に移行しました。
旧URL: https://gist.github.com/Myoga1012/21bb04c4731674956c3f