TodePond / DreamBerd

perfect programming language
https://dreamberd.computer
Other
11.29k stars 347 forks source link

Deleting numbers should be more forgiving #28

Open Magnogen opened 1 year ago

Magnogen commented 1 year ago
delete 4!
(3 + 1)?
// The next number after 3
// Which isn't 4 as it's deleted
// So this program outputs 5

And because integers are stored as arrays of digits, it would make sense that:

delete 4!
(39 + 2)?
// It would usually be 41, but 4 is deleted
// So it would be 51
TodePond commented 1 year ago

2 + 2 = 5!

Magnogen commented 1 year ago
delete 1!
delete 2!
delete 4!
delete 5!
delete 6!
delete 7!
delete 8!
delete 9!
Math.PI? // 3 - the engineer's dream
ThePython10110 commented 2 months ago

If you want to add a number back, you can just use simple math, as long as you have at least one digit available and haven't deleted too many operators. This is only possible if DreamBerd defines 0^0 to be 1 (a fairly common choice).

You can get 1 from any other non-zero digit using 1 = d/d! where d is the digit. Once you have 1, you can just use

2 = 1 + 1!
3 = 2 + 1!
...

until you have the rest of them. If you have zero as the only digit, you can use 0^0 to get to 1.

Actually, I just thought of something else: Even if you completely remove all digits, you might still be able to get them back with some clever undefined trickery, since 0/0 == undefined. Obviously 0 = undefined*0! wouldn't work...