split bugfix? and turtle state fix?

This commit is contained in:
Scott Richmond 2025-07-10 17:12:47 -04:00
parent 273695405e
commit f58046b9a2
2 changed files with 6 additions and 2 deletions

View File

@ -1416,6 +1416,7 @@ fn turtle_listener () -> {
(:position, pid) -> send! (pid, (:reply, do turtle_states > unbox > self () > :position)) (:position, pid) -> send! (pid, (:reply, do turtle_states > unbox > self () > :position))
(:penwidth, pid) -> send! (pid, (:reply, do turtle_states > unbox > self () > :penwidth)) (:penwidth, pid) -> send! (pid, (:reply, do turtle_states > unbox > self () > :penwidth))
(:heading, pid) -> send! (pid, (:reply, do turtle_states > unbox > self () > :heading)) (:heading, pid) -> send! (pid, (:reply, do turtle_states > unbox > self () > :heading))
(:state, pid) -> send! (pid, (:reply, do turtle_states > unbox > self ()))
does_not_understand -> { does_not_understand -> {
let pid = self () let pid = self ()
panic! "{pid} does not understand message: {does_not_understand}" panic! "{pid} does not understand message: {does_not_understand}"
@ -1495,6 +1496,10 @@ fn penwidth {
() -> do turtle_states > unbox > :turtle_0 > :penwidth () -> do turtle_states > unbox > :turtle_0 > :penwidth
} }
fn savestate {
"Returns the turtle's state."
() -> do turtle_states > unbox > :turtle_0
}
&&& fake some lispisms with tuples &&& fake some lispisms with tuples
fn cons { fn cons {

View File

@ -470,8 +470,7 @@ pub fn r#type(x: &Value) -> Value {
pub fn split(source: &Value, splitter: &Value) -> Value { pub fn split(source: &Value, splitter: &Value) -> Value {
match (source, splitter) { match (source, splitter) {
(Value::String(source), Value::String(splitter)) => { (Value::String(source), Value::String(splitter)) => {
println!("splitting {source} with {splitter}"); let parts = source.split(splitter.as_str());
let parts = source.split_terminator(splitter.as_str());
let mut list = vector![]; let mut list = vector![];
for part in parts { for part in parts {
list.push_back(Value::String(Rc::new(part.to_string()))); list.push_back(Value::String(Rc::new(part.to_string())));