Skip to content

Commit

Permalink
make repeat only work on targets
Browse files Browse the repository at this point in the history
  • Loading branch information
tomara-x committed Jun 27, 2024
1 parent e7bbb90 commit 884e2b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ some ops make a circle do things to its targets. like `process`, `del_targets`,
- `target_lt`
- inputs: `n -> 1`
- for hole targets, set their link type to input num
- `repeat`
- inputs: `n`, `T -> 1`
- repeat input targets array n times

</p>
</details>
Expand All @@ -389,9 +392,6 @@ some ops make a circle do things to its targets. like `process`, `del_targets`,
<details><summary>arrays</summary>
<p>

- `repeat`
- inputs: `n -> 1` (repetitions), `A -> 2` or `T -> 2`
- repeat input array (or input targets array) n times
- `zip`
- inputs: `A -> 1`, `A -> 2`
- zip array 1 and array 2
Expand Down
27 changes: 5 additions & 22 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,36 +450,19 @@ pub fn process(
}
}
}
// -------------------- arrays --------------------
13 => { // repeat
let mut arr = None;
let mut targets = None;
let mut n = None;
let mut changed = false;
for hole in holes {
if let Ok(wh) = white_hole_query.get(*hole) {
if wh.link_types == (-1, 1) {
n = Some(access.num_query.get(wh.bh_parent).unwrap().0 as usize);
} else if wh.link_types == (-13, 2) { arr = Some(wh.bh_parent); }
else if wh.link_types == (-14, 2) { targets = Some(wh.bh_parent); }
if wh.open { changed = true; }
}
}
if changed {
if let Some(n) = n {
if let Some(arr) = arr {
let repeated = access.arr_query.get(arr).unwrap().0.repeat(n);
access.arr_query.get_mut(*id).unwrap().0 = repeated;
lt_to_open = Some(-13);
}
if let Some(tar) = targets {
let repeated = access.targets_query.get(tar).unwrap().0.repeat(n);
access.targets_query.get_mut(*id).unwrap().0 = repeated;
if wh.link_types == (-14, 1) && wh.open {
let n = access.num_query.get(*id).unwrap().0 as usize;
let targets = &access.targets_query.get(wh.bh_parent).unwrap().0;
access.targets_query.get_mut(*id).unwrap().0 = targets.repeat(n);
lt_to_open = Some(-14);
}
}
}
}
// -------------------- arrays --------------------
14 => { // zip
let mut arr1 = None;
let mut arr2 = None;
Expand Down

0 comments on commit 884e2b7

Please sign in to comment.