AGSPL
Jump to navigation
Jump to search
AGSPL is a stackbased esoteric programming language created by Xi816. It's inspired by Golfscript, APL and others.
Commands
Operation  Operands  Description 

09

none  Push the number to the stack 
+

int, int  Add two numbers 
array, int  Append int to array  
array, string  Append string to array  
array, function  Map  
array, array  Concatenate  
string, int  Increment ASCII/Unicode value n times  


int, int  Subtract two numbers 
string, int  Delete n symbols from end  
array, int  Pop and discard n elements from array  
*

int, int  Multiply two numbers 
string, int  Duplicate string n times  
string and string  Duplicate every symbol in string 1 n times, where n is length of second string  
/

int, int  Divide two numbers, 
array, int  Separate array by chunks with n elements  
_

int  Negate (n * 1) 
array  Create a range (including last number)  
%

int, int  Modulo (remainder) 
array  Delete all duplicates  
<

int, int  Less than 
array, array  Bitmask less than  
>

int, int  Greater than 
array, array  Bitmask greater than  
=

any, any  Equal 
""

none  Unicode String 
''

none  ASCII String 
[]

none  Array 
{}

none  Function 
.

none  Output as a number (or string, array) 
,

none  Output as a Unicode/ASCII character 
~

none  Number input 
@

none  String input 
!

int  Factorial 
function  Call the function  
$

none  Duplicate the top value in the stack 
&

none  Pop the top value from the stack 
^

none  Swap the top two values in the stack 
`

none  Reverse the stack 
:

none  Store value from stack to the variable 
;

none  Get value from variable to the stack 
?

function, function  If the value in top after calling first function is not 0, then call second function 
#

function, function  While the value in top stack after calling first function is not 0, call second function 
×

array  Sum of all elements 
int, int  Power function  
÷

int and int  Random number between those numbers 
array  Random element from array  
v

block, int  Repeat the block n times 
f

block, array  For loop 
Programs
Cat program:
@.
Factorial:
~!.
Truthmachine:
~$.{$}{.}#
99 Bottles Of Beer:
99:b {;b 2>} { & ;b ." bottles of beer on the wall,".10, ;b ." bottles of beer!".10, "Take one down, and pass it around,".10, ;b 1$:b . " bottles of beer on the wall!".10$,, }# "2 bottles of beer on the wall,".10, "2 bottles of beer!".10, "Take one down, and pass it around,".10, "1 bottle of beer on the wall!".10$,, "1 bottle of beer on the wall,".10, "1 bottle of beer!".10, "Take one down, and pass it around,".10, "No more bottles of beer on the wall!".10$,, "No more bottles of beer on the wall,".10, "No more bottles of beer!".10, "Go to the store, and buy some more,".10, "99 bottles of beer on the wall!".
Nope interpreter:
"Nope.".
Number guessing game:
"Input a number: ".~:n 0:g { ;n "Guess: ".~$:g ¬neq } { & {;n ;g <}{"Lower!".10,}? {;n ;g >}{"Higher!".10,}? }# "You Win!".
Collatz Conjecture:
~:n {;n 1¬neq } {& {;n 2%0=}{&;n 2/:n}? {;n 2%1=}{&;n 3*1+:n}? ;n ¬round :n ;n .32, }#