remove pub from _ functions

This commit is contained in:
Rowan Torbitzky-Lane 2025-04-21 16:35:08 -05:00
parent ce68a225ea
commit 9d017eb6ab
2 changed files with 17 additions and 23 deletions

View File

@ -316,7 +316,7 @@ pub fn code_map(state: &mut PushState) {
/// If top bool is true, execute top element of code/exec stack and skip the second. /// If top bool is true, execute top element of code/exec stack and skip the second.
/// If false, execute second element and skip the top. /// If false, execute second element and skip the top.
pub fn _if(a: Gene, b: Gene, cond: bool) -> Option<Gene> { fn _if(a: Gene, b: Gene, cond: bool) -> Option<Gene> {
Some(if cond { a } else { b }) Some(if cond { a } else { b })
} }
@ -344,7 +344,7 @@ pub fn exec_when(state: &mut PushState) {
/// Pushes true if the second code item is found within the first item. /// Pushes true if the second code item is found within the first item.
/// If the first item isn't a block, coerced into one. /// If the first item isn't a block, coerced into one.
pub fn _member(a: Gene, b: Gene) -> Option<bool> { fn _member(a: Gene, b: Gene) -> Option<bool> {
let block = match b { let block = match b {
Gene::Block(val) => val, Gene::Block(val) => val,
val => vec![val], val => vec![val],
@ -355,7 +355,7 @@ pub fn _member(a: Gene, b: Gene) -> Option<bool> {
/// Pushes the nth item of the top element of the code stack. /// Pushes the nth item of the top element of the code stack.
/// If top code item isn't a block, wrap one around it. /// If top code item isn't a block, wrap one around it.
pub fn _nth(a: Gene, idx: i128) -> Option<Gene> { fn _nth(a: Gene, idx: i128) -> Option<Gene> {
let gene_vec = match a { let gene_vec = match a {
Gene::Block(val) => val, Gene::Block(val) => val,
val => vec![val], val => vec![val],
@ -369,27 +369,21 @@ pub fn _nth(a: Gene, idx: i128) -> Option<Gene> {
} }
/// Pushes an empty block to the top of a stack. /// Pushes an empty block to the top of a stack.
pub fn _make_empty_block<T>() -> Option<Gene> { fn _make_empty_block<T>() -> Option<Gene> {
Some(Gene::Block(vec![])) Some(Gene::Block(vec![]))
} }
/// Checks to see if the top item on the code/exec stack is an empty block. /// Checks to see if the top item on the code/exec stack is an empty block.
/// True if is, False if not. /// True if is, False if not.
pub fn _is_empty_block(a: Gene) -> Option<bool> { fn _is_empty_block(a: Gene) -> Option<bool> {
Some(match a { Some(match a {
Gene::Block(val) => { Gene::Block(val) => val.is_empty(),
if val.is_empty() {
true
} else {
false
}
}
_ => false, _ => false,
}) })
} }
/// Returns the size of the top item on the code/exec stack. /// Returns the size of the top item on the code/exec stack.
pub fn _size(a: Gene) -> Option<i128> { fn _size(a: Gene) -> Option<i128> {
Some(match a.clone() { Some(match a.clone() {
Gene::Block(val) => val.len() as i128, Gene::Block(val) => val.len() as i128,
_ => 1, _ => 1,
@ -397,7 +391,7 @@ pub fn _size(a: Gene) -> Option<i128> {
} }
/// Returns a nested element inside a block based on an int. /// Returns a nested element inside a block based on an int.
pub fn _extract(a: Gene, idx: i128) -> Option<Gene> { fn _extract(a: Gene, idx: i128) -> Option<Gene> {
match &a { match &a {
block @ Gene::Block(_) => { block @ Gene::Block(_) => {
let block_len = block.rec_len(); let block_len = block.rec_len();
@ -415,7 +409,7 @@ pub fn _extract(a: Gene, idx: i128) -> Option<Gene> {
/// Inserts a gene at a given position in into the top block based off an /// Inserts a gene at a given position in into the top block based off an
/// int from the top of the int stack. The top code item is coerced into a block /// int from the top of the int stack. The top code item is coerced into a block
/// if needed. /// if needed.
pub fn _insert(a: Gene, b: Gene, idx: i128) -> Option<Gene> { fn _insert(a: Gene, b: Gene, idx: i128) -> Option<Gene> {
let mut block = match a.clone() { let mut block = match a.clone() {
iblock @ Gene::Block(_) => iblock, iblock @ Gene::Block(_) => iblock,
val => Gene::Block(vec![val]), val => Gene::Block(vec![val]),
@ -431,7 +425,7 @@ pub fn _insert(a: Gene, b: Gene, idx: i128) -> Option<Gene> {
/// Pushes the first position of the 2nd code item within the top code item. /// Pushes the first position of the 2nd code item within the top code item.
/// If not found, pushes -1. If top code item isn't a block, returns 0 if top /// If not found, pushes -1. If top code item isn't a block, returns 0 if top
/// two code items equal, -1 otherwise. /// two code items equal, -1 otherwise.
pub fn _first_position(a: Gene, b: Gene) -> Option<i128> { fn _first_position(a: Gene, b: Gene) -> Option<i128> {
let bad_cond: bool = match &a { let bad_cond: bool = match &a {
Gene::Block(val) => val.len() == 0, Gene::Block(val) => val.len() == 0,
_ => true, _ => true,
@ -456,7 +450,7 @@ pub fn _first_position(a: Gene, b: Gene) -> Option<i128> {
} }
/// Reverses the top block. Does nothing if not a block. /// Reverses the top block. Does nothing if not a block.
pub fn _reverse(a: Gene) -> Option<Gene> { fn _reverse(a: Gene) -> Option<Gene> {
Some(match a { Some(match a {
Gene::Block(mut val) => { Gene::Block(mut val) => {
val.reverse(); val.reverse();

View File

@ -70,31 +70,31 @@ macro_rules! make_code {
} }
/// Duplicates an item /// Duplicates an item
pub fn _dup<T: Clone>(val: T) -> Option<Vec<T>> { fn _dup<T: Clone>(val: T) -> Option<Vec<T>> {
Some(vec![val.clone(), val]) Some(vec![val.clone(), val])
} }
pub fn _dup_times<T: Clone>(amt: i128, val: T) -> Option<Vec<T>> { fn _dup_times<T: Clone>(amt: i128, val: T) -> Option<Vec<T>> {
Some(vec![val; amt as usize]) Some(vec![val; amt as usize])
} }
/// Swaps two values /// Swaps two values
pub fn _swap<T: Clone>(a: T, b: T) -> Option<Vec<T>> { fn _swap<T>(a: T, b: T) -> Option<Vec<T>> {
Some(vec![a, b]) Some(vec![a, b])
} }
/// Rotates three values /// Rotates three values
pub fn _rotate<T>(a: T, b: T, c: T) -> Option<Vec<T>> { fn _rotate<T>(a: T, b: T, c: T) -> Option<Vec<T>> {
Some(vec![c, a, b]) Some(vec![c, a, b])
} }
/// Checks if two values are equal /// Checks if two values are equal
pub fn _equal<T: Eq>(a: T, b: T) -> Option<bool> { fn _equal<T: Eq>(a: T, b: T) -> Option<bool> {
Some(b == a) Some(b == a)
} }
/// Checks if two values are not equal /// Checks if two values are not equal
pub fn _not_equal<T: Clone + Eq>(a: T, b: T) -> Option<bool> { fn _not_equal<T: Eq>(a: T, b: T) -> Option<bool> {
Some(b != a) Some(b != a)
} }