Navigation
[Home] [Console] [Guide] [Applications] [Index] [Back]

Sxript Programming Language


Abstract
Sxript is an interpreted high-level functional/procedural programming language designed for numerical evaluation and problem solving with high-order functions, variable storage, scoped subprograms, and arbitrary-precision numbers, along with file I/O, graphical output, and more. Sxript may be used as a stand-alone tool on most devices, or included as a component of any BASIC, JavaScript, or C++ application.

Browser Instances

Console

Calculator

Clone/Download
sxript-master.zip

git clone https://github.com/wfbarnes/sxript.git

Contact
william (at) barnesreport.net

Legal
Sxript is conveyed as open source free software, as detailed in license.txt.

Logo
Signature of a Medieval Illiterate - Frederick W. Umminger Jr., Yale Record, 1959.


Guide
[Home] [Console] [Guide] [Applications] [Index] [Back]

Overview: All source code is written in a strict subset of the QB45 language, and is auto-translated by the BAS-TO-X utility into languages that obey similar semantics, i.e. C++ and JavaScript. Sxript interfaces with the world as a REPL (read-eval-print-loop). Input is recursively evaluated until a stable result is reached. The nuts-and-bolts of the evaluation loop can be seen here, a projection of the aptly-commented EvalStep() function with all code hidden.
Example-Program.txt
Scroll down to run.
`...All programs are actually subprograms...': Quotes and numbers pass through as stable. Lines are separated by the semicolon ( : ).
include(`../test/arithmetic.txt'): Execute a program on file to load data (variables and/or functions).
print_`Welcome!\n': Print welcome message. Note the newline sequence \n before closing the quote.
let(rollone,dice(6)): Generate a random number from a 6-sided dice and store the result in variable rollone.
print_`Your single dice roll is: ' + quote([rollone]) + `\n': Print the stored result of single dice roll embedded in a quote. The variable reference is replaced by its literal value when enclosed in square brackets ( [] ).
func(rolltwo,{<dice([x]),dice([x])>}): Define a single-line function that rolls two [x]-sided dice and returns a vector.
print_`Your double dice roll is: '
+ quote(rolltwo(6)) + `\n':
Whitespace and break returns only matter within quotes.
func(rollmany,{ Begin a multi-line function. These must occur as a sub(program) or (code)block.
  sub({ Open subprogram. The body consists of occulted code.
let(a,[x]): Input arguments manifest as [x], [y], [z], etc.
let(b,[y]): Store second argument in a variable b.
do: Begin a loop that iterates b times.
print_dice([x]),: Return the result of an [x]-sided dice roll.
loop: Re-iterate if count less than b.
  • Elementary statements from imperative programming, namely if, goto, do/loop, etc. are available within any (and limited to the same) given subprogram or codeblock.

  • Variables and functions defined in a subprogram are destroyed as the subprogram closes. The only output carried away by the sub is what follows print.

  • To preserve variables and functions defined in a subprogram, use a codeblock.
  }) Close subprogram.
}): End definition of function rollmany.
print_rollmany(6,10) Call rollmany function to roll 6-sided dice 10 times and print the result.

sub({
})


Applications
[Home] [Console] [Guide] [Applications] [Index] [Back]

(#)
24 Game
100 Doors
A
Analytic Functions
Arithmetic
B
Bitwise Operations
C
Calculus
Callbacks
Coconut Pyramids
Combinator
Complex Functions
Complex Numbers
Conway's Game of Life
Currying
D
Dinesman Dwelling Problem
E
Epoch Clock
Epoch Clock (Reverse)
Example
F
Fern Fractal
Fibonacci Numbers
Fibonacci Shortcut
FizzBuzz
Flower by Turtle Graphics
G
Generalized Mutiplication
Golden Ratio
H
Hash Function
Hash Table
Haskell Imitation
High-Order Functions

I
Icons
J
K
Koch Fractals
L
Large Precision Numbers
Linear Algebra
List Memorization
M
Math Constants
Matrix Operations
N
Nonlinear System (2D by Inverse)
Nonlinear System (N=2D)
Nonlinear System (N=3D)
Nth
O
Objects
P
Pascal Triangle
Permutation of a String
Points on a Circle
Polynomial Regression
Q
R
Roots of a Function

S
Sierpinski Triangle
Sorting Algorithms
Square Root Table
Statistics
String Tools
Sxript Alpha
Symplectic Integrator
T
Time Core
Tree Traversal
U
V
Variable Management
Vector Tools
W
Water Collected Between Towers
X
Y
Z


Index
[Home] [Console] [Guide] [Applications] [Index] [Back]

(*) : $
A : alet , anchor , apply , asc , atan
B : block
C : chr , column , cos
D : do
E : elem , exe
F : for , func
G : goto , greater
H

I : if_@ , iff , include , instr , int
J
K
L : lambda , large(*/+-) , lcase , left , len , let , loop
M : map , mid
N : Number Type
O : Occult Type , Operators
P : print
Q : Quote Type
R : rand , reduce , replace , report , reset , right

S : sin , smooth , stack , sub
T : tan , tilde , type
U : ucase
V : Vector Type
W : Whitespace
X
Y
Z