#l-systems #lindenmayer

lsystems

A simple library for working with Lindenmayer systems

2 releases

Uses old Rust 2015

0.2.1 Jan 21, 2017
0.2.0 Jan 21, 2017
0.1.0 Feb 6, 2016

#4 in #lindenmayer

27 downloads per month

GPL-3.0 license

16KB
121 lines

Introduction

This project aims to provide a simple interface for working with L-systems in the Rust programming language.

Examples

let mut system = LSystem::with_axiom("b");
system.add_rule('a', "ab");
system.add_rule('b', "a");

for step in 0..10 {
    println!("Step #{}: {}", step, system.next().unwrap());
}
let mut system = LSystem::with_axiom("baaaaaaa");
system.add_rule('b', "a");
system.add_context_rule((Some("b"), 'a', None), "b");

assert_eq!(system.next().unwrap(), "baaaaaaa");
assert_eq!(system.next().unwrap(), "abaaaaaa");
assert_eq!(system.next().unwrap(), "aabaaaaa");
assert_eq!(system.next().unwrap(), "aaabaaaa");
assert_eq!(system.next().unwrap(), "aaaabaaa");
assert_eq!(system.next().unwrap(), "aaaaabaa");
assert_eq!(system.next().unwrap(), "aaaaaaba");
assert_eq!(system.next().unwrap(), "aaaaaaab");
assert_eq!(system.next().unwrap(), "aaaaaaaa");

lib.rs:

A library that makes working with L-systems simple. Works with chars as predecessors and Strings as successors.

Examples

use lsystems::LSystem;
let mut system = LSystem::with_axiom("b");
system.add_rule('a', "ab");

Dependencies

~315–540KB