JavaScript
ネタ
可読性
記号プログラミング

今度はなんじゃ

可読性の高いコードを書きましょうという記事を見て、過去にこんな記事を書いている以上は便乗しなければならないと思い、賞味期限の切れた野菜生活100を飲みながら、素数を列挙した配列を返すJavaScriptを書いてみました。

コード

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       _
                                                               =[                                                                                                         ...[                                                                                                                                                                                                                                                                                                                                                                        ][($                                    +                                        [])[
                -~-~                       -    ~[]]    +      (({                                                                                  })+[            ]      )[-~        []]                                                                                                                                                                                                                                                                                                                                                            +($+                                   [])[-    ~-                     ~[]       ]+(!
                []+[                     ])[-   ~-~-   ~[]]   +(!!                             []                     +[])[+[]]+(!![]+[])           [-~[          ]]+(     $+[]        )[-~                            []]+                                                                                                                                                                                                                                                                                                      ($+[])[-~-~-~        []]+              (!![]+[])[+[]]+(     ({})   +[])               [-~[]]+(!      ![]+[
  ])[-~[]]](~-~-~-~[]*~-~-~-~[]*~-       ~-~-~  []*~   -~-~   -~[]                            +~-~-                   ~[])[[][($+[])[-~-~  -~[]     ]+((          {})+      [])[      -~[]]                            +($+                                                                                                                                                   [])[-~-~                                                   []]+                                                                                    (![]+[])[-~-~-~[]]+(!![]+[])[+[]]+(    !![]+[])[-~[]]+(    $+[])   [-~[]       ]+($+[])[-~-~-~[ ]]+(!![]+[])[+[]]+
  (({})+[])[-~[]]+(!![]+[])[-~[]]]        [($+  [])[  -~-~    -~[]                            ]+((                    {})+[])[-~[]]+($+[]  )[-~     -~[]           ]+(!     []+[      ])[-                             ~-~-                                                                  ~[]]+                                                                          (!![]+[])[+[]                                                ]+(!                                                                                    ![]+[])[-~[]]+($+[])[-~[]]+($+[])[-    ~-~-~[]]+(!![]+[    ])[+     []]+(      ({})+[])[-~[]]+( !![]+[])[-~[]]]((!
  ![]+[])[-~[]]+(!![]+[])[-~-~-~[]         ]+(! ![]+ [])[     +[]]                            +($+                    [])[-~[]]+(!![]+[])  [-~[     ]]+(           [][[]     ]+[]    )[-~[                              ]]+                    (/ /+[])[-~[]]+(/"/+[])[-~                    []]+(                                                                         /\\/+[])[-~[]]+                                               ($+[                                  ])[-                                              ~[]]+-[]+-[]+-~-~-~-~-~-~[]+(({})+[        ])[- ~-~       []]+(      /"/+      [])[-~[]])()     +(!![]+[])[-~-~-~[
                ]]+(                       -~[] /+[] +[])    [~(~[]+~[]<<-~-~                [])]                           +(![]          +[])     [-~-            ~-~[     ]]](    )][(                               (+[]                   )[(({})+[])[-~-~-~-~-~[]]                     +(({}                                                                        )+[])[-~[]]+($+[                                               ])[-                                  ~-~[                                                  ]]+     (![]+[])[-~-~-~[]]+(!![        ]+[] )[+       []]+(    !![]+[]      )[-         ~[] ]+($          +[])
                [-~[                        ]   ]+((   {     })+[])[-~-~-~-~-     ~[]]+(!![]+[])[+[]]+(({})+[])             [-~[]          ]+(!     ![]+     [])[-~[]]]+[])[(-~-~-~[]<<-~-~[])+~                        []]+                   (![]+[])[-~[]]+((/ /[($+[                     ])[-~                                                                        -~-~[      ]]+((                                                                                     {})+                                                  [])           [-~[                     ]]+( [][    ![]]+[])[-~[]]+(![]           +[]    )[-~-~-~          []]+
   (!![]+[])[+[]]+(!![]+[])[-~[]]       +($+[])[-~[]]+($+[]  )[-~-~-~[]]+(!![     ]+[])[+[]]+(({})+[])[-~[]]+(!             ![]+           [])[     -~[]     ]])+[])[~(~[]+~[]<<-~-~[])*-~-~[]]]      ([][($+[])[-~-~-~[]]+(({})+[])[-~        []]+($+[])[-~-~[]]+(![]+[                     ])[-~                                                                       -~-~[          ]]                                                                                     +(!!                      []+[])[+                   []]+           (!![     ]+              [])[ -~[    ]]+($+[])[-~[]]+($+[    ])[-  ~-~-   ~[]]+(!![]+[])[+[]]+((
   {})+[])[-~[]]+(!![]+[])[-~[]]]       [($+[])[-~-~-~[]]+( ({})+[])[-~[]]+($     +[])[-~-~[]]+(![]+[])[-~-~-~[            ]]+(!           ![]+     [])[     +[]]+(!![]+[])[-~[]]+($+[])[-~[]]+(      $+[])[-~-~-~[]]+(!![]+[])[+[]]+((                          {})+[]                      )[-~[                                                                       ]]+(                                                                                                  !![]                   +[])[-~[]]](($                +[])          [-~[]    ],(!          ![]+[])[-~[]]+(!![]+[])[-~-~-~[]]+(     !![  ]+[]  )[+[ ]]+($+[])[-~[]]+(!
   ![]+[])[-~[]]+([][[]]+[])[-~[]       ]+(/\[/+[])[-~-~[]] +(/.      /+[]        )[-~[]]+(/./+[])[-~[]]+(/./+[            ])[-~[]]+(([]   [($+     [])[              -~-~-        ~[]]               +(({})+[])[-~[]]+([][![]]+[])[-~[                         ]]+(![                       ]+[])                                                                       [-~-                                                                                                  ~-~[                 ]]+(!![]+[])[+[]]+              (!![          ]+[]     )[-~[         ]]+($+[])[-~[]]+($+[])[  -~-~   -~      []]+ (!![  ]+[] )[+[]]+(({})+[])[-
                ~[]]                         +(!![]+[])     [-~[      ]]])                 +[])                            [-~-~-~[]*-~-   ~-~[     ]]+(             !![]+          [])[              -~[]]+(!![]+[])[-~[]]+(![]+[])[-~                        []]+(-                        ~[]/+                                                                       []+[                                                                                                  ])[~                (~[]+~[      ]<<-~-~             [])           ]+/*      #*/(         /\(/+[])[-~-~[]]    +(~  -~-~           []*~  -~-  ~[]* ~-~-          ~-~-
                ~[]*                        ~-~-~-~-~[]*   ~(~-~-     ~-~[                ]*~-~                           -~-~[])*~(~-~-   ~-~[     ]*~-            ~-~-~         []))+/*                               #*/(                                 /\)/+[                          ])[-~        -~[]]+(/./                                  +[])[-~[]]         +[][                        ($+[])[-~       -~-~      []]       +(({        })+    [])[-~             []]+               ($+[]            )[-~-           ~[]]          +(![       ]+[])        [-~-~-~ []] +(!!    []+  [])[   +[]      ]+(  !![]+[])  [-~[          ]]+(
$+[])[-~[]]+($+[])[-~-~-~[]]+(!![]+[       ])[+[]]+(({})+  [])[-~     []]+                (!![                            ]+[]      )[-~   []]]     [($+           [])[-~-~-~[]]+(({})+[])                               [-~[                               ]]+($+                           [])[-      ~-~[]]+(![]+[]       )[-~          -~-~[    ]]+(!![]+[])[+       []]+(                     !![]+[])[-~       []]+   ($+[])       [-~[        ]]+( $+[])[-~-~       -~[]]+(!![]+[])       [+[]                ]+((          {})+          [])[     -~[]]+(!       ![]+[]) [-~ []]]   ((!!  []+[   ])[      -~[] ]   +(!!  []+[])[-~-~-~[]]+(
!![]+[])[+[]]+($+[])[-~[]]+(!![]+[])      [-~[] ]+([ ][[] ]+[])[-~    []]+               (/ /                            +[])[      -~[]   ]+/*     #*/(          /"/+[])[-~[]]+(/\\/+[])[-                       ~[]]+  ($+[                              ])[-~[                            ]]+-[      ]+-[]+-~-~-~-~-      ~-~[          ]+((     {})+[])[-~-~[]]       +(/"/                   +[])[-~[]])(       )+(!  ![]+[])       [-~-        ~-~[]]+(-~[]/+[]      +[])[~/*#*/(~[]      +~[]                  <<-~         -~[])]+(![ ]+[])[-~-~-~[]]+'()]       .'+((+[ ])[ (({}  )+[]   )[-~   -~-      ~-~      -~[   ]]+(({})+[])[-~[]]
+($+[])[-~-~[]]+(![]+[])[-~-~-~[]]+(     !![]+  [])[  +[  ]]+(!![]    +[])              [-~[]                            ]+($       +[])   [-~[     ]]+(        ({})+[])[-~-~-~-~-     ~[]]+                   (!![]+[])[+[]]                             +(({})                             +[])[      -~[]      ]+(!!      []+[]         )[-~     []]]      +[])[        /*#*/                 (-~-~      -~       []<< -~-~[])+       ~[]]        +(![]+[    ])[-~      []]+((/ /[($+[]      )[-       ~-~-~  []]+  (({        })+[])[-~[] ]+([][![]]+[])[-~[]]+      (![]+[] )[- ~-~- ~[]]+   (!![]+[])[          +[]]       +(!![]+[])[-~[]]+(
       $     +[])[-~    []]+            ($+[]   )[-~     -~-~[]]+(    !![               ]+[]                            )[+[]      ]+((    {})+     [])[       -~[]]+        (!![       ]+[])[                -~[]]])+[])[~(~                            []+~[]<<                            -~-~[                 ])*-~      -~[]        ]+/*#                ##*/(       /\(/+[])             [-~-~                []]+(![]            +[])        [+[]]       +(/=/         +[])            [-~[     ]]+(/>/+[])[-  ~[]]       +(/\(/+[])[ -~-~[]]+($+[])[-~[]]+(     /\+/+[] )[- ~-~[]]+-~ -  ~[]+(/\)/+          [])[       -~-~
      []]   +(/\*/     +[])[-            ~-~    []]+     (/\( /+[]   )[-~              -~[]]+(![]      +                [])[+[     ]]+(    /\+/     +[])     [-~-~[]         ]+-~        -~[]+/*            #*/(/\)/+[])[-~-~                          []]+(/\)/+[])                         [-~-~                  []])      )[(!        ![]+                  [])[         -~[]]+(!           ![]+                 [])[-~              -~-~        []]+(        [][[         ]]+[            ])[     -~-~[]]+($+[])   [-~      []]+($+[])[- ~-~-~[]]+         (!![     ]+[])[- ~-~ -~[]]]([ ][($+[])[-~-~      -~[]]+(({})+[]) [-~[
     ]]+($+[])[-~    -~[]]+(              !              []+[ ])[-   ~-~-             ~[]]+(!![]+[])[+[]]+(!           ![]+[])[-   ~[]]    +($+     [])[    -~[]]+(          $+[]         )[-~-~           -~[]]+       (!![]+                        [])[+[]]+(({})+                        [])[-                  ~[]]      +(!![       ]+[]                  )[-~          []]][($+[        ])[-~                 -~-~[               ]]+(        ({})         +[])[        -~[]           ]+($    +[])[-~-~[]]+(!   []+     [])[-~-  ~-~[                   ]]       +(!![]+ [])[+[]]+(!  ![]+               [])[-~[]]+($+[] )[-~[]]+($+[])[-~-~
     -~[]]+(!![     ]+[])[+                   []]+         (   ({})  +[])            [-~[]]+(!![]+[])[-~[]]           ](($+[])[-~ []],(    ![]+     [])[     +[]],(!![]+[])[-~[]]+(!![]+[])[-~-~           -~[]]         +(!![]                        +[])[+[]]+($+[]                       )[-~[                  ]]+(       !![]      +[])[                  -~[]            ]+([][[]       ]+[]                  )[-~[               ]]+(        / /+          [])[        -~[]           ]+(     $+[])   [-~[]]     +/*    #*/(/./  +[])  [-~[  ]]+(   $+[]         )[-~-~- ~[]]+(({ }  )+[])               [-~[]]+($+[])[- ~-~[]]+($+[])[-~-~-
       ~[]]+(!    []+[])[    -                ~[]]             +(!!  []+[            ])[+[]   ]+(/\(/+[])[-          ~-~[]]+(![]+[])[+     []]+     (/\)     /+[ ])[-~-~[]]))[(!![]+[])[-~[  ]]+          (!![]          +[])[-                         ~-~     -~[]]+(                      [][[]           ]+[])[-~-~[       ]]+(      $+[]            )[-~[]]+($+               [])[-~      -~-~                  []]+(               !![]        +[])          [-~-        ~-~[           ]]]    ([][(     $+[])     [-~   -~-~[]]+  (({}  )+[]  )[-~   []]+         ($+[])  [-~-~[]]    +(![]+[])[-~-~-          ~[]]       +(!![]+[])[+[]]+(!!
        []+[])[ -~[]]+($    +[]         )[-~[]]+($+[])[-~-~-   ~[]] +(!!            []+[]    )[+[]]+(     (          {})+[  ])[-~[]]+(     !![]     +[])         [-~[]]][($+[])[-~-~-~[]]+(               ({})          +[])[-~[                                   ]]+($                     +[])[        -~-~[]]+(![]+[       ])[-      ~-~-         ~[]]+(!![]+[])                 [+[]]     +(!!                  []+[                ])[-        ~[]]          +($+        [])[           -~[    ]]+($     +[])[     -~-    ~-~[]]+  (!![  ]+[]  )[+[   ]]+(         ({})+[      ])[-   ~[]]+(!![]+[])[-          ~[]]       ](($
         +[])[-~[]],(!     []+[]        )[+[]],(!![]+[])[-~[   ]]+(!![]+            [])[    -~-~-~[]]+                (!!     []+[])[+     []]+     ($+[                     ])[-                         ~[]]         +(!![]+[]                                    )[-~                     []]+(       [][[]]+[])[-~[]        ]+(/      /+[        ])[-~[]]+($+[])                  [-~[     ]]+(                  /./+                [])[        -~[]          ]+($        +[])           [-~    -~-~      -~-~[     ]]+    ($ +[])  [-~-  ~[]]  +($+   [])[         -~-~-~      []]+  (![]+[])[-~-~[]]+          ($+[       ])[-
           ~[]]+([][        []]+[       ])[-~-~[]]+(!![]+[])    [-~-~-~[              ]     ]+(!  []+[                ])       [-~-~-      ~[]]     +/*#                     #*/(                         /\(/        +[])[-~-~[                             ]]+(![]+[])                     [+[]]      +(/\)/      +[])        [-~-    ~[]]        +(/\?/      +[])                   [-~-    ~[]]                  +($+                [])[        -~[]          ]+/*        ####           */(    /:/+      [])[-     ~[]    ]+ (/\[  /+[]  )[-~  -~[]   ]+/*         ###*/       (/./ +[])[-      ~[]]+     (/./+[])[-~[]]+( /./+[])[-~[]]+($+[]
  )[-~[]]+(/,/+[])[-~[]]+(![]+[])[          +[]]     +/*#       */(/\]/                    +[])   [-~-                          ~[]])      ,[])     ;;;[                     ...[                         ][($+[  ])[-~-~-~ []]+                           (({})+[])[-~[                     ]]+($     +[])[        -~-~        []]+    (![]       +[])[        -~-~                   -~[]    ]+(!                  ![]+                [])[        +[]]          +(!!        []+[           ])[    -~[]      ]+($      +[]       )[-~  []]+  ($+[  ])[-   ~-~-         ~[]]        +(!![]+[])[      +[]]+     (({})+[])[-~[]]+ (!![]+[])[-~[]]](~-
 ~-~[]*~-~-~[]*~-~-~-~-~[]*~-~-~-~-        ~[]*~    (~-~         -~-~[]                    *~-~    -~-~                        [])*~       (~-~     -~-~    []*~-~-~-~[]))[[][($+[])[-~-~-~[]]+(           ({})+[])[-~[]]+  ($+[                          ])[-~-~[]]+(![                     ]+[])     [-~-         ~-~[         ]]+(   !![]       +[])         [+[]                   ]+(!    ![]+                  [])[                -~[]        ]+($          +[])        [-~[           ]]+    ($+[     ])[-~     -~-~       []]+  (!![ ]+[])  [+[]   ]+((         {})+[])[-~[]]+(!![]+[])[    -~[]]      ][($+[])[-~-~-~[ ]]+(({})+[])[-~[]]+
 ($+[])[-~-~[]]+(![]+[])[-~-~-~[]]+(       !![]    +[])[         +[]]+                     (!![    ]+[]                       )[-~[        ]]+(     $+[]    )[-~[]]+($+[])[-~-~-~[]]+(!![]+[])[+           []]+(({})+[])[   -~[]                         ]+(!![     ]+[]                    )[-~[]     ]]((         !![]         +[])  [-~[        ]]+(         !![]                   +[])    [-~-~                 -~[]                ]+(!        ![]+         [])[+        []]+           ($+[   ])[-~   []]+(!     ![]+       [])[  -~[] ]+([   ][[]   ]+[]  )[-    ~[]]+(/ /+[])[-~[]]  +(/"  /+[])            [-~[]]             +  //  ////
 (/\\/+[])[-~[]]+($+    []      )[-~      []]+-[]+ -[]+          -~-~-                     ~-~-    ~-~                       []+(({        })+[     ])[-    ~-~[]]+(/"/+[])[-~[]])()+(!![]+[])[-             ~-~-~[]]+(     -~[]                         /+[]       +[])                    [~(~[]     +~[]        <<-~-         ~[])  ]+(!        []+[        ])[-~                  -~-~[     ]]](                 )][(                ![]+        [])[-        ~-~-         ~[]]            +(!   []+[])[-~-~[]]   +($+[        ])[-  ~-~- ~-~-   ~[]]   +($+  [])    [-~-~-~[]]+(!![] +   [])[-~-~-~[            ]]](-~-   ~[])[(![]+[ ])[ +[]]
         +($    +[])   [-~-~    -~        -~-~[]]+(![]+         [])[-~-                    ~[]]                             +(!![]                  +[])                     [+[]                              ]+(!!        []+[                        ])[-        ~-~-                   ~[]]+(      !![]+      [])[-~          []]  ]([         ][($+      [])[-~      -~          -~[]]     +(({}                )+[]                )[-~        []]+(       $+[])         [-~-            ~[]]   +(![]+[])[-~-~-~[]]+         (!![  ]+[] )[+[   ]]+(   !![]  +[]    )[-~        []]+      ($+[])[-~            []]+($+[]  )[-~-~- ~[] ]+( !![]
       +[])[+   []]+   (({})+[               ])[-~[]]+(        !![]+[])[                   -~[]]                           ][($+[                   ])[-                     ~-~-                                           ~[]]                        +(({}     )+[])[        -~[]      ]+($+[]      )[-~-~    []]+(![          ]+[] )[-         ~-~-~[    ]]+(!![      ]+[]      )[+[]]       +(!![      ]+       [])[                -~[]        ]+($+[]    )[-~[          ]]+($            +[]   )[-~-~-~[ ]]+(!![]+          [])[+[]]+(({})+   [])[   -~[]  ]+(    !![]        +[])       [-~[]]]            (($+[ ])[-~[]], (!! []+ []) [-~[
     ]]+(!![    ]+[]   )[-~-~-~[               ]]+(!![]+[    ])[+[] ]+($+                   [])[-        ~                []]+(!                    ![]+                     [])[                                           -~[]                         ]+([][[]]+[])[         -~[]]+(/!/+[])[-        ~[]]+(/_/+[ ])[-          ~[]]+(/.          /+[])[-~[]] +($+      [])[-~-~-~-~-~[]        ]+($+[])[-~-       ~[]]                +($+        [])[-~-~-~[]]+(            ![]+[])[-~      -~[]    ]+($+    [])[-~[           ]]+([][[]]+[])    [-~-   ~[]]  +(!    ![]+        [])[     -~-~-~[]]+           (![]   +[])[-~- ~-~ []] +(/\(/+[
  ])[-~-~[]     ]+($     +[])[-~[]          ]+(/\)/+[])[-~  -~[]])   )////                   /////////////               //////                     ////                     ////                                          ////                          /////////////          ///////////////          /////////  ////           //////            /////////  ////      ///////////////          ///////////       ////                ////        //// /////////             //////////       ////                              //////////////    ////   //// ////    ////////////////   ///////////////      //////    /////// /// ///  // ////
 ////////       ////       ////////      /////////   //// ///////     //////                 //////////////            ///////                //////////                     ////                                          ////                           ///////////           //////////////            //////    ////           //////             //////    ////       /////////////             ////////        ////                ////        ////   //////                ///////         /////           ///              ////    /////     ////   //// ////    /////////////////////////  /////////   //////      / //// /// ////////////
  /////         ////         //////     /////////      // //////       /////                   ////////////            //////                 //////////             ////////////                                         ////                              ///////                /////////                                                                                 /////////                                                               ////                                          //////       /////              ////   //////     ////   /////////    ///////////////////////      ///////   /////         ///  //// ///////////
  ///           ////           ///       //////           ////          ////                     ////////               ///                   //////////             ////////////                                        /////                                                                                                                                                                                                                       ////                                           /////////////////              ////    ////      ////   ////////     ////           //////          /////    ///         ////  ///   /////////
                ////                     //                //             /                                              /                    /////////              ///////////                                          ///                                                                                                                                                                                                                        ////                                             //////////////                        //       ////    ///////     ////           ///                /      /           ///         ///////
                                                                                                                                                                     //////////                                            /                                                                                                                                                                                                                         ////                                               /////////
                                                                                                                                                                                                                                                                                                                                                                                                                                                     ////
                                                                                                                                                                                                                                                                                                                                                                                                                                                     ////
                                                                                                                                                                                                                                                                                                                                                                                                                                                     ////
                                                                                                                                                                                                                                                                                                                                                                                                                                                     ////

動作検証方法

  1. about:blankを開き、
  2. Ctrl + Shift + K (macOS: ⌘Command + ⌥Option + K) を押下し、
  3. コンソールにフォーカスを入れてソースを貼り付け、
  4. Enterで実行!
  5. 非常に計算が遅いので、その間に賞味期限切れの野菜生活100のストックを消費しましょう。

あとがき

こんなことに時間を潰してしまったことを非常に後悔しています。