Edit README
This commit is contained in:
parent
350fbb701d
commit
d54527413d
40
README.md
40
README.md
@ -1,21 +1,5 @@
|
|||||||
# Dust
|
# Dust
|
||||||
|
|
||||||
<!--toc:start-->
|
|
||||||
- [Dust](#dust)
|
|
||||||
- [Features](#features)
|
|
||||||
- [Usage](#usage)
|
|
||||||
- [Installation](#installation)
|
|
||||||
- [The Dust Programming Language](#the-dust-programming-language)
|
|
||||||
- [Variables and Data Types](#variables-and-data-types)
|
|
||||||
- [Commands](#commands)
|
|
||||||
- [Lists](#lists)
|
|
||||||
- [Maps](#maps)
|
|
||||||
- [Tables](#tables)
|
|
||||||
- [The Yield Operator](#the-yield-operator)
|
|
||||||
- [Functions](#functions)
|
|
||||||
- [Time](#time)
|
|
||||||
<!--toc:end-->
|
|
||||||
|
|
||||||
Dust is a data-oriented programming language and interactive shell. Dust can be used as a replacement for a traditional command line shell, as a scripting language and as a tool create or manage data. Dust is expression-based, has first-class functions, lexical scope and lightweight syntax.
|
Dust is a data-oriented programming language and interactive shell. Dust can be used as a replacement for a traditional command line shell, as a scripting language and as a tool create or manage data. Dust is expression-based, has first-class functions, lexical scope and lightweight syntax.
|
||||||
|
|
||||||
A basic dust program:
|
A basic dust program:
|
||||||
@ -43,6 +27,22 @@ read("examples/assets/faithful.csv")
|
|||||||
-> plot(input)
|
-> plot(input)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<!--toc:start-->
|
||||||
|
- [Dust](#dust)
|
||||||
|
- [Features](#features)
|
||||||
|
- [Usage](#usage)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [The Dust Programming Language](#the-dust-programming-language)
|
||||||
|
- [Variables and Data Types](#variables-and-data-types)
|
||||||
|
- [Commands](#commands)
|
||||||
|
- [Lists](#lists)
|
||||||
|
- [Maps](#maps)
|
||||||
|
- [Tables](#tables)
|
||||||
|
- [The Yield Operator](#the-yield-operator)
|
||||||
|
- [Functions](#functions)
|
||||||
|
- [Time](#time)
|
||||||
|
<!--toc:end-->
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Data visualization: GUI (not TUI) plots, graphs and charts are available from directly within dust. No external tools are needed.
|
- Data visualization: GUI (not TUI) plots, graphs and charts are available from directly within dust. No external tools are needed.
|
||||||
@ -60,11 +60,15 @@ Dust is an experimental project under active development. At this stage, feature
|
|||||||
|
|
||||||
You must have the default rust toolchain installed and up-to-date. Clone the repository and run `cargo run` to start the interactive shell. To see other command line options, use `cargo run -- --help`.
|
You must have the default rust toolchain installed and up-to-date. Clone the repository and run `cargo run` to start the interactive shell. To see other command line options, use `cargo run -- --help`.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Please submit any thoughts or suggestions for this project. To contribute a new command, see the library documentation. Implementation tests are written in dust and are run by a corresponding rust test so dust tests will be run when `cargo test` is called.
|
||||||
|
|
||||||
## The Dust Programming Language
|
## The Dust Programming Language
|
||||||
|
|
||||||
Dust is a hard fork of [evalexpr]; a simple expression language. Dust's core language features maintain this simplicity. But it can manage large, complex sets of data and perform complicated tasks through commands. It should not take long for a new user to learn the language, especially with the assistance of the shell.
|
Dust is a hard fork of [evalexpr]; a simple expression language. Dust's core language features maintain this simplicity. But it can manage large, complex sets of data and perform complicated tasks through commands. It should not take long for a new user to learn the language, especially with the assistance of the shell.
|
||||||
|
|
||||||
If your editor supports tree sitter, you can use [tree-sitter-dust] for syntax highlighting and completion support.
|
If your editor supports tree sitter, you can use [tree-sitter-dust] for syntax highlighting and completion support. Aside from this guide, the best way to learn dust is to read the examples and tests to get a better idea of what dust can do.
|
||||||
|
|
||||||
### Variables and Data Types
|
### Variables and Data Types
|
||||||
|
|
||||||
@ -166,7 +170,7 @@ insert(
|
|||||||
|
|
||||||
assert_eq(length(animals.all), 6);
|
assert_eq(length(animals.all), 6);
|
||||||
|
|
||||||
animals.by_name = sort_by(animals.all, "name");
|
by_name = sort_by(animals, "name");
|
||||||
```
|
```
|
||||||
|
|
||||||
### The Yield Operator
|
### The Yield Operator
|
||||||
|
@ -8,7 +8,7 @@ impl Macro for Transform {
|
|||||||
fn info(&self) -> MacroInfo<'static> {
|
fn info(&self) -> MacroInfo<'static> {
|
||||||
MacroInfo {
|
MacroInfo {
|
||||||
identifier: "transform",
|
identifier: "transform",
|
||||||
description: "Change each value with a function.",
|
description: "Alter a collection by calling a function on each value.",
|
||||||
group: "collections",
|
group: "collections",
|
||||||
inputs: vec![ValueType::ListOf(vec![
|
inputs: vec![ValueType::ListOf(vec![
|
||||||
ValueType::List,
|
ValueType::List,
|
||||||
@ -418,150 +418,3 @@ impl Macro for Where {
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::Function;
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn where_from_non_collections() {
|
|
||||||
Where
|
|
||||||
.run(&Value::List(vec![
|
|
||||||
Value::Integer(1),
|
|
||||||
Value::Function(Function::new("input == 1")),
|
|
||||||
]))
|
|
||||||
.unwrap_err();
|
|
||||||
Where
|
|
||||||
.run(&Value::List(vec![
|
|
||||||
Value::Float(1.0),
|
|
||||||
Value::Function(Function::new("input == 1.0")),
|
|
||||||
]))
|
|
||||||
.unwrap_err();
|
|
||||||
Where
|
|
||||||
.run(&Value::List(vec![
|
|
||||||
Value::Boolean(true),
|
|
||||||
Value::Function(Function::new("input == true")),
|
|
||||||
]))
|
|
||||||
.unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn where_from_list() {
|
|
||||||
let arguments = Value::List(vec![
|
|
||||||
Value::List(vec![Value::Integer(1), Value::Integer(2)]),
|
|
||||||
Value::Function(Function::new("input == 1")),
|
|
||||||
]);
|
|
||||||
let select = Where.run(&arguments).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(Value::List(vec![Value::Integer(1)]), select);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn where_from_map() {
|
|
||||||
let mut map = VariableMap::new();
|
|
||||||
|
|
||||||
map.set_value("foo", Value::Integer(1)).unwrap();
|
|
||||||
map.set_value("bar", Value::Integer(2)).unwrap();
|
|
||||||
|
|
||||||
let arguments = Value::List(vec![
|
|
||||||
Value::Map(map),
|
|
||||||
Value::Function(Function::new("input == 1")),
|
|
||||||
]);
|
|
||||||
let select = Where.run(&arguments).unwrap();
|
|
||||||
|
|
||||||
let mut map = VariableMap::new();
|
|
||||||
|
|
||||||
map.set_value("foo", Value::Integer(1)).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(Value::Map(map), select);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn where_from_table() {
|
|
||||||
let mut table = Table::new(vec!["foo".to_string(), "bar".to_string()]);
|
|
||||||
|
|
||||||
table
|
|
||||||
.insert(vec![Value::Integer(1), Value::Integer(2)])
|
|
||||||
.unwrap();
|
|
||||||
table
|
|
||||||
.insert(vec![Value::Integer(3), Value::Integer(4)])
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let arguments = Value::List(vec![
|
|
||||||
Value::Table(table),
|
|
||||||
Value::Function(Function::new("foo == 1")),
|
|
||||||
]);
|
|
||||||
let select = Where.run(&arguments).unwrap();
|
|
||||||
let mut table = Table::new(vec!["foo".to_string(), "bar".to_string()]);
|
|
||||||
|
|
||||||
table
|
|
||||||
.insert(vec![Value::Integer(1), Value::Integer(2)])
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(Value::Table(table), select);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn select_from_non_collections() {
|
|
||||||
Select
|
|
||||||
.run(&Value::List(vec![Value::Integer(1), Value::Integer(1)]))
|
|
||||||
.unwrap_err();
|
|
||||||
Select
|
|
||||||
.run(&Value::List(vec![Value::Float(1.0), Value::Float(1.0)]))
|
|
||||||
.unwrap_err();
|
|
||||||
Select
|
|
||||||
.run(&Value::List(vec![
|
|
||||||
Value::Boolean(true),
|
|
||||||
Value::Boolean(true),
|
|
||||||
]))
|
|
||||||
.unwrap_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn select_from_list() {
|
|
||||||
let arguments = Value::List(vec![
|
|
||||||
Value::List(vec![Value::Integer(1), Value::Integer(2)]),
|
|
||||||
Value::Integer(0),
|
|
||||||
]);
|
|
||||||
let select = Select.run(&arguments).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(Value::List(vec![Value::Integer(1)]), select);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn select_from_map() {
|
|
||||||
let mut map = VariableMap::new();
|
|
||||||
|
|
||||||
map.set_value("foo", Value::Integer(1)).unwrap();
|
|
||||||
map.set_value("bar", Value::Integer(2)).unwrap();
|
|
||||||
|
|
||||||
let arguments = Value::List(vec![Value::Map(map), Value::String("foo".to_string())]);
|
|
||||||
let select = Select.run(&arguments).unwrap();
|
|
||||||
|
|
||||||
let mut map = VariableMap::new();
|
|
||||||
|
|
||||||
map.set_value("foo", Value::Integer(1)).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(Value::Map(map), select);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn select_from_table() {
|
|
||||||
let mut table = Table::new(vec!["foo".to_string(), "bar".to_string()]);
|
|
||||||
|
|
||||||
table
|
|
||||||
.insert(vec![Value::Integer(1), Value::Integer(2)])
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let arguments = Value::List(vec![Value::Table(table), Value::String("foo".to_string())]);
|
|
||||||
let select = Select.run(&arguments).unwrap();
|
|
||||||
|
|
||||||
let mut table = Table::new(vec!["foo".to_string()]);
|
|
||||||
|
|
||||||
table.insert(vec![Value::Integer(1)]).unwrap();
|
|
||||||
|
|
||||||
assert_eq!(Value::Table(table), select);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,22 @@
|
|||||||
list = (1, 2, 3);
|
|
||||||
|
|
||||||
|
# transform
|
||||||
|
list = (1, 2, 3);
|
||||||
test = transform(list, 'input + 1');
|
test = transform(list, 'input + 1');
|
||||||
assert_equal((2, 3, 4), test);
|
assert_equal((2, 3, 4), test);
|
||||||
|
|
||||||
test = get(list, 0);
|
# string
|
||||||
assert_equal(1, test);
|
test = string(42);
|
||||||
|
assert_equal("42", test);
|
||||||
|
|
||||||
|
test = string(42.42);
|
||||||
|
assert_equal("42.42", test);
|
||||||
|
|
||||||
|
test = string(false);
|
||||||
|
assert_equal("false", test);
|
||||||
|
|
||||||
|
# count
|
||||||
|
|
||||||
|
test = count("123");
|
||||||
|
assert_equal(3, test);
|
||||||
|
|
||||||
|
# create_table
|
||||||
|
Loading…
Reference in New Issue
Block a user