A quick tour of Neo.
Start with the bracket model, then follow the same rules through vectors, uncertainty, programs, native compilation, and the Neo interpreter.
Three bracket types
Neo makes the difference between typed data, mixed data, and executable code visible.
[ ]Homogeneous dataTyped vectors and matrices.( )Heterogeneous dataDictionaries, mixed values, and stored code.{ }ExecutionCalls, functions, control flow, and blocks.[1 2 3 4] ; homogeneous data (name:"Neo" version:3) ; dictionary data {+ 1 2} ; executable call
The same function works on scalars and vectors
Define the operation once. A scalar call returns a scalar. A vector call lifts the same function across the data.
{def square (x) {* x x}} {square 5} {square [1 2 3 4]} {+ [1 2 3] 10}
25
[1 4 9 16]
[11 12 13]Arithmetic, comparisons, functions, and control flow participate in the same model.
Unknown and error are ordinary values
? represents unknown or missing data. ! represents a runtime error value. Both can appear inside normal vectors.
{var readings [21.4 ? 22.8 23.1]} {missing? ?} {missing? 42} {mean readings}
T
F
22.4333333333Statistics such as mean, variance, sd, min, and max operate on known entries.
Three-way control flow
A Neo condition may be true, false, or unknown. A vector condition selects a branch for each element.
{if [T F ?] [10 20 30] [1 2 3] [100 200 300]}
[10 2 300]Element-wise or Cartesian
Normal vector operations are element-wise. The @ spread operator requests every combination.
{+ [1 2 3] [10 20 30]} ; [11 22 33] {+ @[1 2] @[10 20 30]} ; [[11 21 31] [12 22 32]]
Strings use vector-style operations
Concatenation, push, and pop work on strings. Compiled programs can read user arguments with args.
{& "Neo" " language"} {push "Ne" "o"} {pop "Neo"} {print {args}}
"Neo language"
"Neo"
"Ne"neo show-args.neo -o show-args.exe .\show-args.exe alpha beta
("alpha" "beta")Code can remain data
Store executable vectors inside (), transform the data, and cross into execution explicitly with {run}.
{var pipeline ({print "read"} {print "transform"} {print "write"})} {run pipeline} {set pipeline {& pipeline ({print "complete"})}}
Numerical computing is built in
mean variance sd min maxmatmul transpose outer identity tracerelu sigmoid softmax mse cross-entropycomplex re im conj abs argquat-normalize quat-inv quat-rotatefilter reduce sort find JSON dictionaries{var z (3 4i)} {abs z} {* 2 1i} {/ 2i 2} {def layer (input weights bias) {relu {+ {matmul input weights} bias}}}
5
2i
1iCompile a Neo program
The Windows installer includes Neo, its runtime headers, and examples.
neo --version neo --doctor neo hello.neo -o hello.exe .\hello.exe
hello world! from NeoBuild and run the interpreter written in Neo
The interpreter source lives at Neo-interpreter-written-in-Neo/src/interpreter.neo. Compile it with the native Neo compiler, then open the REPL.
neo .\Neo-interpreter-written-in-Neo\src\interpreter.neo -o .\Neo-interpreter-written-in-Neo\interpreter.exe .\Neo-interpreter-written-in-Neo\interpreter.exe
Neo REPL. Type :quit to exit.
>Run a file first and the REPL continues with the same persistent environment:
.\Neo-interpreter-written-in-Neo\interpreter.exe .\program.neo