Javaの講義、試験が「自作関数を作り記述しなさい」って問題だったから
「ズン」「ドコ」のいずれかをランダムで出力し続けて「ズン」「ズン」「ズン」「ズン」「ドコ」の配列が出たら「キ・ヨ・シ!」って出力した後終了って関数作ったら満点で単位貰ってた
そこで、AppleScriptで作ってみた。
『ズン』と『ドコ』はログの履歴のメッセージに表示され、『キ・ヨ・シ!』は結果に表示される。
比較演算子さえも英語のように記述できるAppleScriptの特徴がよく出ていると思う。
(もちろん記号でもOK。)
『ズン』と『ドコ』はログの履歴のメッセージに表示され、『キ・ヨ・シ!』は結果に表示される。
比較演算子さえも英語のように記述できるAppleScriptの特徴がよく出ていると思う。
(もちろん記号でもOK。)
set zundoko to {}
repeat while zundoko as string is not equal to "ズンズンズンズンドコ"
set r to random number from 0 to 1
if r is equal to 0 then
set zd to "ズン"
else
set zd to "ドコ"
end if
log zd
set the end of zundoko to zd
repeat while ((count zundoko) is greater than 5)
set zundoko to rest of zundoko
end repeat
end repeat
return "キ・ヨ・シ!"
repeat while zundoko as string is not equal to "ズンズンズンズンドコ"
set r to random number from 0 to 1
if r is equal to 0 then
set zd to "ズン"
else
set zd to "ドコ"
end if
log zd
set the end of zundoko to zd
repeat while ((count zundoko) is greater than 5)
set zundoko to rest of zundoko
end repeat
end repeat
return "キ・ヨ・シ!"