esolang

Daydream

A program is one number. It prints a sequence its author saw in a dream.

Hakerh400, 2022 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 1 0 1 2 4 8 16 32 8 72

The idea

Hakerh400 found Daydream in 2022, as the specification puts it, rather than invented it. The author saw the specification in a dream and wrote it down even though the language is useless. The whole source is one natural number n, and the output is the first n terms of one fixed sequence. Input is ignored.

The machine

The sequence starts with 1. Term k is the sum of every earlier term that k does not divide.

TermEarlier terms that countValue
0none, it is 1 by definition1
1none, 1 divides everything0
21, as 2 divides 01
81, 1, 2 and 48
9all but 072

From term 2 to term 7 only the 0 is left out, so each term is the sum of all the ones before it and the sequence doubles. Term 8 drops back because 8, 16 and 32 are multiples of 8. The specification says 72 is the first positive term that is not a power of two. The terms are printed with a space between them and a line feed at the end, as the Haskell does it.

Example

The first line gives the ten terms the specification lists.
Expected: 1 0 1 2 4 8 16 32 8 72 144 288 72 648 1296 2592 816 5184 888 12072

The first line gives the ten terms the specification lists. Term 12 falls back to 72, because 12 divides 72, 144 and 288 and leaves only 1, 1, 2, 4, 8, 16, 32 and 8.

Further

Ideas it shows

Also in Jokes

Write your own in Run Convert a program from Daydream

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: daydream.

Command line

shib run daydream -e '10'
shib manual daydream

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/daydream.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org