Edited at
EsolangDay 16

純粋関数型難解プログラミング言語を自作した

Esolang Advent Calendarの16日目になるはずだった記事です。盛大に遅刻しました。ごめんなさい。

以前書いたもののボツにしてしまった記事を練り直していくうちに、急にGitHubで公開することを思い立ってドキュメントを全て英語で書き直したりしていたら、こんなにも遅くなってしまいました。


今回公開したのは、Nutsという名前の難解プログラミング言語です。

使える文字は、なんと、' " . , :の5種類1で、あのbrainf*ckの8種類を下回っています2!さらに可読性の悪い文字ばかり使っているので、brainf*ckよりも酷い見た目になります。

こちらが、Nutsで書いたHello worldです。

,,,,,,'''''',,:'',..,,........ .. .,,:...,,:..,,:'',..,..,..,,... .. .,,:.,,:'',..,..,..,..,..,..,..

,..,,... .. .,,:......,,:.....,,:.,,:..,,:..,,:'',..,,..... .. .,,:...."','',..,..,..,..,..,..,..,..
.,'',..,..,..,.. . .','',..,..,..,..,..,..,..,..,..,..,.. .,'',..,..,..,.. . .','',..,..,..,..,..,..
,..,..,.. .,'',..,..,..,..,..,..,..,.. . .','',..,..,..,..,..,..,..,..,..,.. .,'',..,..,..,..,..,..,
..,..,..,.. . .','',..,..,..,..,..,..,..,..,..,..,..,.. .,'',..,..,..,..,..,..,..,..,.. . .'',..,,''
,..,..,..,..,..,..,..,..,..,..,.. .,'',..,..,..,..,..,..,..,..,..,.. . .. .

......何だ,......これは......

といった感じのインパクトのある見た目になっていますね。

Nutsはラムダ計算に基づいている、というかほぼラムダ計算そのものなので、文法自体は非常にシンプルです。関数の定義と適用だけで成り立っています。

詳しくは、仕様書をご覧ください。

Nutsには入出力の機能がありますが、逆転の発想で参照透過性を成り立たせています。副作用をなくすというより、かき消しています。これについても、仕様書で説明しています。

オンラインのインタープリタも公開しているので、是非触ってみてください。サンプルプログラムもあります。


追伸:

チューリング完全なので、クワインもできます。

,,,,,,,,,,''''''',,. ......,,. ..,,. .....,,. .....,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. .....,,. .....,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. .....,,. .....,,. ...,,. ..,,. ....,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. .....,,. .....,,. ...,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. .....,,. .....,,. ...,,. .....,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ....,,. ..,,. ....,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. .....,,. .....,,. ...,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. .....,,. .....,,. ...,,. .....,,. ...,,. ...,,. .....,,. .....,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ...,,. ...,,. .....,,. .....,,. ..,,. ..,,. ....,,. ..,,. ....,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ...,,. ...,,. .....,,. .....,,. ..,,. ....,,. ..,,. ..,,. ...,,. ..,,. ..,,. ...,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ...,,. ...,,. .....,,. .....,,. ..,,. ..,,. ..,,. ......,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ....,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. .....,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ..,,. ....,,. ..,,. ..,,. ...,,. ...,,. ...,,. ...,,. ...,,. ...,,. ......,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. .....,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. .....,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. .....,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. .....,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ...,,. .....,,. ..,,. .....,,. ..,,. ..,,. ...,,. ...,,. ...,,. ...,,. ...,,. ...,,. ...,,. ..,,. ....,,. ..,,. ..,,. .......,,. ...,,. ...,,. ..,,. ..,,. ..,,. ..,,. ...,,. .....,,. .....,,. .....,,. ...,,. ...,,. .....,,. .....,,. .....,,. ...,,. .....,,. ...,,. .....,,. .....,,. .....,,. .....,,. .....,,. .....,,. ...,,. ...,,. ...,,. ...,,. ...,,. ...,,. .....,,. .....,,. .....,,. ...,,. ...,,. ...,,. ..,,. ....,,. ..,,. ..,,. ..,,. ..,,. ....,,. ..,,. ..,,. ...,,. ...,,. ..,,. ..,,. ....,,. ..,,. ..,,. ..,,. ...,,. ...,,. .....,,. .....,,. .....,,. .....,,. ..,,. ..,,. ..,,. ..,,. ..,,. ..,,. .....,,. .....,,. .....,,. .....,,. .....,,. .....,,. ..,,. ..,,. ..,,. ..,,. ..,,. .....,,. .....,,. .....,,. .....,,. .....,,. .....,,. ..,,. ..,,. ..,,. ..,,. .....,,. .....,,. .....,,. .....,,. .....,,. .....,,. ..,,. ..,,. ..,,. .....,,. .....,,. .....,,. .....,,. .....,,. .....,,. ..,,. ..,,. .....,,. .....,,. .....,,. .....,,. .....,,. .....,,. ..,,. .....,,. .....,,. .....,,. .....,,. .....,,. .....,,. ..,,. .....,,. .....''.''''''.''''''..''''''...''''''....''''''.....''''''......'''',,... ..,,.. .... .,,,''',,,,,,'''''',',''',,''',....,,:.. .,,,,,,,..'.',.... .',....,.... .',....,....,.... .',....,....,....,.... .',....,....,....,....,.... .,,:.....,,:.....,,:.......,,:.....,,:......,,:......",,,,,,.. ..... ...... ....... ........ ......... ..........',,:... .,,:....,,:....,,:....,,:....,,:....,,:....,,:....,,:..,,:..,,:..,,:..,,:..,,:..,,:..,,:..,,:..,,:.."...'',,... ..,..,.. .'',,... ..,..,..,..,..,..,..,.. . . ..'',,.... ..,..,.. .'',,','',..,..,..,..,..,..,.. .,'',..,..,..,..,..,..,..,.. . . ..,..,.. .','',..,..,..,.. .,'',..,..,..,..,..,..,..,..,..,..,.. . .,'',..,..,..,..,.. .'',..,.. .''."

かなり長いですが...。

誰かもっと短いの考えてください。

12/22 追記

ちょっと短くなりました。

,,,,',,,,,,'''''',.....,.,....,....,.,...,.,.,..,.,.,..,....,....,.,...,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,....,....,..,.,...,.,...,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,....,....,..,.,...,.,.,..,.,.,..,.,.,..,.,.,..,....,....,..,....,.,...,.,.,..,.,.,..,.,.,...,.,...,.,...,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,....,....,..,.,...,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,....,....,..,....,..,..,....,....,.,...,.,.,..,.,.,..,.,.,...,.,.,.,.,..,..,....,....,.,.,...,.,...,.,...,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,..,.,.,...,.,.,.,..,..,....,....,.,...,.,.,..,.,.,..,.,.,...,.,.,.,..,..,....,....,.,.,.,.....,.,.,......,..,..,.,.,......,..,..,.,.,......,..,..,.,.,......,..,..,.,.,.,.,......,..,..,.,.,......,..,..,.,.,......,..,..,.,.,......,..,..,.,.,......,..,..,.,.,......,..,..,.,.,......,..,..,.,.,.,.,......,..,..,.,.,.,.,......,..,..,.,.,.,.,......,..,..,.,.,.,.,......,..,..,.,.,.,.,......,..,..,.,.,.,.,......,..,..,.,...,.,.,.,......,..,..,....,.,.,.,.,.,.,.,.,.,.,...,.,.,.,.,.,.,.,.,.,...,.,.,.,.,.,.,.,.,...,.,.,.,.,.,.,.,...,.,.,.,.,.,.,...,.,.,.,.,.,...,.,.,..,..,..,..,..,..,.....,.,.,.,.,.,.,......,..,..,.,.,.,.,.,......,..,..,.,...,.,.,.,.,..,.,.,.,.,..,.,.,.,.,..,.,.,.,.,..,.,.,.,.,..,....,.,...,.,.,.,.,..,.,.,.,.,..,.,.,.,.,..,.,.,.,.,..,....,.,...,.,.,.,.,..,.,.,.,.,..,.,.,.,.,..,....,.,...,.,.,.,.,..,.,.,.,.,..,....,.,...,.,.,.,.,..,....,.,....,.,.,..,..,..,..,..,..,..,.,...,.,.,......,..,..,.,.,.,.,..,....,....,....,..,..,....,....,....,..,....,..,....,....,....,....,....,....,..,..,..,..,..,..,....,....,....,..,..,..,.,...,.,.,.,.,...,.,.,..,..,.,.,...,.,.,.,..,..,....,....,....,....,.,.,.,.,.,.,....,....,....,....,....,....,.,..,.,.,.,.,.,....,....,....,....,....,....,.,..,.,.,.,.,....,....,....,....,....,....,.,..,.,.,.,....,....,....,....,....,....,.,..,.,.,....,....,....,....,....,....,.,..,.,....,....,....,....,....,....,.,..,.,....,....''.,.''''''.,.''''''..,.''''''...,.''''''....,.''''''.....,.''''''......'''',,... ..,,.. .... .,,,''',,,,,,'''''',',''',,''',....,,:.. .,,,,,,,..'.',.... .',....,.... .',....,....,.... .',....,....,....,.... .',....,....,....,....,.... .,,:.....,,:......",,,,,,.. ..... ...... ....... ........ ......... ..........',,:... .,,:....,,:....,,:....,,:....,,:....,,:....,,:..,,:..,,:..,,:..,,:..,,:..,,:....,,:..,,:..,,:..,,:.."...'',,... ..,..,.. .'',,... ..,..,..,..,..,..,..,.. . . ..'',,.... ..,..,.. .'',,','',..,..,..,..,..,..,.. .,'',..,..,..,..,..,..,..,.. . . ..,..,.. .','',..,..,..,.. .,'',..,..,..,..,..,..,..,..,..,..,.. . .,'',..,..,..,..,.. .'',..,.. .''."





  1. ;で始まる行コメントもサポートされています。 



  2. Lazy Kでは、2種類の文字だけでプログラミングできたりしますが。