Funciton/99 bottles of beer on the wall
Jump to navigation
Jump to search
This is a Funciton program that outputs the lyrics to “99 bottles of beer on the wall”. It requires several of the library functions.
╔════╗
║ 99 ║
╚═╤══╝
┌──┴──╖
│ 99b ║
╘══╤══╝
│
╓┬────╖
╔════╗ ┌───╖ ╟┘99b ║
║ −1 ╟──┤ + ╟──┐ ╙──┬──╜
╚════╝ ╘═╤═╝ ├──────────────────────────┴─────────────────────────────┐
╔════╗ ┌─┴─╖ │ ╔════════════════════════════════════════════════════╗│
║ 99 ╟──┤ ? ╟──┘ ║ 93438979891487426396059469986395555362079573844971 ║│
╚════╝ ╘═╤═╝ ║ 71377306928718494179034460561943201885027745835961 ║│
┌──┴───╖ ║ 98129935108241412387473531261660077880505710501626 ║│
│ 99bp ║ ║ 32694396343717333192558234646820019070451056711 ║│ ╔═════════════════════════════════════════════════════╗
╘══╤═══╝ ╚══════════════════════════╤═════════════════════════╝│ ║ 99 Bottles of Beer on the Wall (main function) ║
┌─┴─╖ ┌───╖ ┌─┴─╖ ╔═════════════════╗ │ ╟─────────────────────────────────────────────────────╢
│ ‼ ╟───────────────────────┤ ‼ ╟──┤ ? ╟──╢ 445551776368547 ║ │ ║ 99b(x) = ║
╘═╤═╝┌─────────────────────┐╘═╤═╝ ╘═╤═╝ ║ 925186328623383 ║ │ ║ let a = 99bp(x); ║
│ │╔═══════════════════╗│ │ │ ║ 851314944882510 ║ │ ║ let b = x ? "Take one down, pass it around,\n" ║
│ │║ 15177132563375318 ║│ │ │ ║ 812246570019017 ║ │ ║ : "Go to the store, buy some more,\n"; ║
╔════════╗ │ │║ 07655616350359109 ║│ │ │ ║ 240477365113929 ║ │ ║ let c = 99bp(x ? x−1 : 99); ║
║ 318287 ║ │ │║ 82597577171382437 ║│ │ │ ║ 659548419629671 ║ │ ║ a ‼ " on the wall,\n" ‼ a ‼ ".\n" ‼ b ‼ ║
║ 023073 ║ │ │║ 18150105146396039 ║│ │ │ ║ 952755268258505 ║ │ ║ c ‼ " on the wall.\n\n" ‼ (x ? 99b(x−1) : "") ║
║ 603558 ║ │ │║ 2022986808360992 ║│ │ │ ║ 759402210908648 ║ │ ╚═════════════════════════════════════════════════════╝
║ 743780 ║ │ │╚══════════╤════════╝│ │ │ ║ 737406010882693 ║ │
║ 068900 ║ │ │ ┌─┴─╖ ┌───╖ │ │ │ ║ 018745757193818 ║ │
║ 028319 ║ │ │ │ ‼ ╟─┤ ‼ ╟─┘ │ │ ║ 597439618635403 ║ │
║ 948400 ║ │ │ ╘═╤═╝ ╘═╤═╝ │ │ ║ 821854707881243 ║ │
║ 620075 ║ │ │ ┌─┴─╖ │ ┌─┴─╖ │ ║ 92049082452 ║ │
║ 955580 ║ │ └─────┬───┤ ‼ ╟────────┤ ‼ ║ │ ╚═════════════════╝ │
║ 347161 ║ │ │ ╘═══╝┌──────┐╘═╤═╝ └─────────────┐ │
║ 651333 ║ │ ╔═══╗│┌──────╖│╔════╗│ ╔╧═════════╗ │ │
║ 590970 ║ │ ║ 0 ║└┤ 99bp ╟┘║ −1 ║└┐║ 20971566 ║ ├────────────┘
║ 678045 ║ │ ╚══╤╝ ╘══════╝ ╚══╤═╝ │╚══════════╝ │
║ 336290 ║ ┌─┴─╖ ┌─┴─╖ ┌─────╖ ┌┴──╖├──────────────────────┘
║ 721824 ╟──┤ ‼ ╟──┤ ? ╟──┤ 99b ╟──┤ + ║│
╚════════╝ ╘═══╝ ╘═╤═╝ ╘═════╝ ╘═╤═╝│ ╓┬──────╖
└───────┬───────┘ │ ╟┘ 99bp ║
└──────────┘ ╙───┬───╜
┌────────────────────────────────────────────────┴──────────────┐
│╔══════════════════════════════════════════╗╔═══════════╗ │
│║ 8592134145756414358602136806465202028576 ║║ 232783950 ║ │ ╔══════════════════════════════════════╗
│╚══════════════════════════════╤═══════════╝╚╤══════════╝ │ ║ 99 Bottles (helper function) ║
│ ┌───╖ ╔═══╗ ┌─┴─╖ ┌───╖ ┌─┴─╖ ┌─────────╖ │ ╟──────────────────────────────────────╢
└───────────────┤ = ╟──╢ 1 ║ │ ‼ ╟──┤ ‼ ╟──┤ ? ╟──┤ int→str ╟──┴┐ ║ 99bp(x) = ║
╘═╤═╝ ╚═══╝ ╘═╤═╝ ╘═╤═╝ ╘═╤═╝ ╘═════════╝ │ ║ let a = (x ? int→str(x) : "No"); ║
╔═══╗ ┌─┴─╖ ┌─┴─╖ │ └──────────────────┘ ║ let b = (x = 1 ? "" : "s"); ║
║ 0 ╟──┤ ? ╟─────────┤ ‼ ╟──┐ ║ a ‼ " bottle" ‼ b ‼ " of beer" ║
╚═══╝ ╘═╤═╝ ╘═══╝ │ ╚══════════════════════════════════════╝
╔════╧╗╔════════════════╧════════════════════════════════╗
║ 115 ║║ 20338288213193790107412311132593873016630280224 ║
╚═════╝╚═════════════════════════════════════════════════╝