Standard library
This section is still a work in progress
The Aya standard library consists of type definitions, mathematical functions, string and list operations, plotting tools and even a small turtle graphics library. It also defines functions and objects for working with colors, dates, files, GUI elements, and basic data structures such as queues, stacks, and sets. The standard library also contains a file which defines extended ASCII operators for use when code golfing.
asciiart
Provides an asciiart datatype and several operator overloads for drawing complex ascii art pictures with only a few characters.
Run length encoding:
aya> " #` # #`5#"_
asciiart:
#
# #
#####
Operator overloads
aya> " #` # #`5#"_ T
asciiart:
#
##
# #
##
#
aya> " #` # #`5#"_ $I
asciiart:
#
# #
#####
# #
# # # #
##### #####
# # # # #
# # # # # # # # # #
#########################
bitset
Provides the bitset
type
aya> 8 bitset! :b
[ 0 0 0 0 0 0 0 0 ]bitset!
aya> 3 b.set
aya> 5 b.set
aya> b
[ 0 0 0 1 0 1 0 0 ]bitset!
aya> b.count
2
canvas
Graphics library for creating images and animations. See
examples/canvas
for more examples.
color
The color
library defines basic color constructors and conversions.
aya> 14 57 100 color!
(14 57 100) color!
aya> color.colors.violet :violet
(238 130 238) color!
aya> violet.hsv
[ 300 .45378151 .93333333 ]
aya> violet.hex
"ee82ee"
aya> 5 color.colors.red color.colors.blue.grad
[
(255 0 0) color!
(191 0 63) color!
(127 0 127) color!
(63 0 191) color!
(0 0 255) color!
]
csv
Provides functions for reading and writing CSV files
aya> "examples/data/simple.csv" csv.read
{,
[
[ 1 2 3 ]
[ 4 5 6 ]
[ 7 8 9 ]
]:data;
nil:rownames;
[ "A" "B" "C" ]:colnames;
}
dataframe
The dataframe
type is an interface for working with tables. CSV
files can be directly imported and modified or the data can be generated
by the program itself.
aya> {, [[1 2 3][4 5 6]]:data ["x" "y" "z"]:colnames} dataframe!
x y z
0 | 1 2 3
1 | 4 5 6
aya> {, [[1 2 3][4 5 6]]:data ["x" "y" "z"]:colnames} dataframe! :df
x y z
0 | 1 2 3
1 | 4 5 6
aya> df.["x"]
[ 1 4 ]
aya> "examples/data/simple.csv" dataframe.read_csv
A B C
0 | 1 2 3
1 | 4 5 6
2 | 7 8 9
date
The date script provides a basic interface for the date parsing
operators Mh
and MH
. It also provides basic date unit addition
and subtraction.
aya> date.now
May 01, 2017 12:53:25 PM
aya> date.now.year
2017
aya> date.now 2 dates.month +
Jul 01, 2017 8:53:42 AM
aya> date.now 2 dates.month + .mmddyy
"07/01/17"
enum
The enum
library defines the enum
keyword which uses
dictionaries and metatables to create enums.
aya> enum shape {circle triangle square}
aya> shape
shape
aya> shape :T
::enum
aya> shape.circle
shape.circle
aya> shape.circle :T
::shape
aya> shape.circle shape.circle =
1
golf
golf
defines many short variables that are useful when golfing. It
also uses the Mk
operator to add additional single character
operators. In the following code, all variables ì
, ¶
, ¦
,
¥
and r
are defined in the golf script.
aya> .# Generate and print an addition table
aya> 6r_춦¥
0 1 2 3 4 5
1 2 3 4 5 6
2 3 4 5 6 7
3 4 5 6 7 8
4 5 6 7 8 9
5 6 7 8 9 10
Sets default values for many variables
aya> [ a b c d k l p w z ì í]
[ 2 3 10 1000 [ ] 3.14159265 -1 0 {+} {-} ]
image
Library for reading and writing images.
aya> "images/logo.png" image.read :img
(image 300x300)
aya> img.width
300
aya> img.pixels 5 .<
[
[ 255 255 255 ]
[ 255 255 255 ]
[ 255 255 255 ]
[ 255 255 255 ]
[ 255 255 255 ]
]
io
Defines the file
and path
types
json
Library for reading and writing json
math
The math
library provides many math functions
matrix
The matrix
library provides a basic interface and operator overloads
for working with matrices.
aya> 3 3 10 matrix.randint :mat
| 7 8 2 |
| 8 7 3 |
| 8 4 4 |
aya> mat [[0 1] 0] I
| 7 |
| 8 |
aya> mat [[0 1] 0] I .t
| 7 8 |
aya> mat 2 ^ 100 -
| 29 20 -54 |
| 36 25 -51 |
| 20 8 -56 |
missing
Provides the missing
type for working with missing data
mp
Metaprogramming library
plot
Plotting interface. See examples/plot
queue
Queue data structure.
random
Functions for woring with random numbers.
set
The set
script defines a set
type and many operator overloads.
It defines s
as a prefix operator for the set constructor allowing
the syntax s[ ... ]
to create sets.
aya> s[1 2 3 2 2 1] .# == ([1 2 3 2 2 1] set!)
s[ 1 2 3 ]
aya> s[1 2 3] s[2 3 4] |
s[ 1 2 3 4 ]
aya> s[1 2 3] s[2 3 4] &
s[ 2 3 ]
aya> s[1 2 3] s[2 5] /
s[ 1 3 ]
shell
A shell-like interface for the aya REPL.
socket
Socket and socket server interface.
stack
Stack data structure.
stats
Provides several statistics functions.
sys
Provides functions for working with the system such as getting or changing the working directory.
terminal
Functions for formatting text in the terminal (bold, color, etc)
turtle
Turtle library. See examples/turtle
viewmat
Provides the viewmat
function which is used to generate a heatmap
visualization of a 2d array. See examples/canvas/julia