az

From Esolang
Jump to navigation Jump to search

az is an esoteric programming language drawing inspiration from all-over.

a3 b5 i1
[
    c0! ca+ cb+
    ac0+! [? a3 s"Fizz".0]
    bd0+! [? b5 s"Buzz".0]
    cd|! [? i# d0] 10.
    c1i+ c101^ ?
]

Design

  • Each command is a single ascii character.
  • White space is optional and comments are ( in parens ).
  • There are 26 local variables named a-z.
  • Specifying a variable makes it current.
  • Commands always execute on the current variable.
  • The previous current variable is tracked too (like a 2-cell stack).
  • Integer literals are specified directly in base 10.
  • String literals are supplied as double-quoted strings.
  • Words of three or more letters are global named variables.
  • Functions are first-class, passed as integer references.
  • Zero is false. Non-zero is true.

Commands

Cmd Description
( Start comment
) End comment
a-z Make local variable current
A-Z Make outer variable current (calling scope)
"..." current = string
0-9 current = integer
[ Begin loop
? Break loop if current is false
] Repeat loop
{ Start function
} End function, current = function reference
# Output integer
; Call function in current
+ current = current + previous
- current = current * -1 (negate)
< current = current << previous (shift left)
> current = current >> previous (shift right)
& current = current AND previous
| current = current OR previous
^ current = current XOR previous
! current = (current == 0) ? -1: 0
\ current = (current < 0) ? -1: 0
, Read character from stdin
. Write character (or string) to stdout
$ Execute system shell command
@ Make local variable current (by numeric index)
word Make global named variable current

Fibonacci

a0 b1 [ b# c32.0+ ac+ ba0+ cb0+ cd100-+\ ?]

Factorial

a1 b5 c0! [ ad0+ be0+ [ce+?da+] cb+ ?] a# 0

Beer

d { B"s" Aa1^! [?B0] }
e { a"#A bottle$B of beer on the wall,".10. }
f { a"#A bottle$B of beer.".10. }
g { a"Take one down, pass it around,".10. }
h { b"#A bottle$B" Aa0+! [? b"No bottles" a0] b. }
i { a" of beer on the wall.".10.. }
a99 [ a? d; e; f; g; c0!a+ d; h; i; ] 0

Brainfuck

( 64k source, 64k tape )
a32768@

( read source to cell 26 )
a26 [ b,? a@0+ c1a+ ]

( tape pointer )
a16384
( source pointer )
b26

( bracket tracking )
x { EG^! [? a1F+ z] EH^! [? a0!F+ z] }

[
    b@c0+ ? (c = command)

    c (>) d62 ^! [? 1a+   z]
    c (<) d60 ^! [? 0!a+  z]
    c (+) d43 ^! [? 1a@+  z]
    c (-) d45 ^! [? 0!a@+ z]
    c (.) d46 ^! [? a@.   z]
    c (,) d44 ^! [? a@,   z]
    c ([) d91 ^! [? f1 a@d0+! [? e1  b+@e0+ g91 h93 x; f ]]
    c (]) d93 ^! [? f1 a@d0+  [? e0! b+@e0+ g93 h91 x; f ]]
 
    c1b+
]

External resources