readme update
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Joe Bellus 2022-10-16 21:47:56 -04:00
parent 357cbd4b05
commit 1c1b4f74f6
2 changed files with 21 additions and 100 deletions

View File

@ -3,9 +3,24 @@
Abacus core provides the scripting and calculation engine for [[../][Abacus]].
For General information visit [[../][Abacus]]
For information on the UI application visit [[abacus-ui/][Abacus UI]].
For information on the UI application visit [[../abacus-ui/][Abacus UI]]
* Scripting Reference
** Datatypes
The following data types are supported:
| Name | Note |
| Integer | Any integer constant without a decimal place |
| Float | Any number constant written with a decimal place |
| Array | A list of values of the same type surrounded by [] |
| Map | A dictionary of key value pairs |
| Boolean | True and false constants |
| Series | An array used for fast calculations |
| Dataframe | A map of series used for fast calculations |
| String | An array of characters, uses double quotes |
| Char | A single character, uses single quotes |
* Scripting
** Everything is an expression
Everything can be evaulated as an experession. This means variables can be set to if blocks, loops, or anything else;
#+begin_src rust

View File

@ -1,101 +1,7 @@
* Abacus UI
* Scripting
** Everything is an expression
Everything can be evaulated as an experession. This means variables can be set to if blocks, loops, or anything else;
#+begin_src rust
let x = if y == "test" { 1 } else { 2 };
#+end_src
Abacus UI is the desktop GUI for [[../][Abacus]].
** Returning output
Output is rendered based on the returned value of a block. The final value of the block is automatically returned. The return keyword is only needed if an early return is preferable.
#+begin_src rust
if x == 0 {
return 0;
}
For General information visit [[../][Abacus]]
For information on the scripting visit [[../abacus-core/][Abacus Core]]
if x > 10 {
// note the lack of a semicolon here
x / 5
} else {
// note the lack of a semicolon here
x / 10
}
#+end_src
** Variables
Variables can be assigned using the let keyword. Variables are dynamically typed and globally mutable:
#+begin_src rust
let pulse_rate = 0.8;
let time = 3.2;
time / pulse_rate
#+end_src
** Functions
Functions can be defined using the fn keyword. Return types and arguments are dynamic and do not require typing.
#+begin_src rust
fn add_one(x) {
x + 1;
}
add_one(2)
#+end_src
** Object maps
Dictionary style data maps are possible and can be index or accessed by a property notation. Dictionaries are defined using a special syntax wrapper: #{}.
#+begin_src rust
let account = #{ first_name: "Alice", last_name: "Allison", balance: 150.32 };
// Access via property notation
account.balance += 10;
// Access via indexing
account["last_name"] = "Test";
account
#+end_src
** Series
A series provides a powerful way to perform calculations on an array of data. Operations performedon the series are performed against all of its member values. Serieses are constructed using the series fucntion and passing an array of values.
#+begin_src rust
let s = series([1,2,3,4]);
// Return an array of values calculated from the series
[ s + 10, s * s ]
#+end_src
** Dataframes
Dataframes provide an object for working with tabular data made up of several series. Dataframes are initialzied using the dataframe constructor function and passing in an object map container name/array pairs.
Dataframe series can be accessed via indexing or property notation just like object maps.
#+begin_src rust
let df = dataframe(#{
name: ["Alice", "Bob", "Charles"],
rate: [18,20,20],
hours: [22,40,55]
});
df.balance = df.rate * df.hours;
df
#+end_src
*** Filtering
Dataframes are more powerful than object maps and can be filtered. Filtering requires two parts:
1. Selecting the columns to be included
2. providing a predicate to filter a column's value
The filtering syntax is FROM <dataframe> <column array> : <array of predicates>
Predicates consist of a quoted name for the series/column an operator and a value. Valid operators are: gt, gte, lt, lte.
Filtering returns a new dataframe with the extracted values.
#+begin_src rust
let df = dataframe(#{
name: ["Alice", "Bob", "Charles"],
rate: [18,20,20],
hours: [22,40,55]
});
let high_rates = from df ["name", "rate", "hours"] : ["rate" gte 20];
high_rates.balance = high_rates.rate * high_rates.hours;
high_rates
#+end_src