Macros for efficient development

Examples

```rust use doe::*; //get argument and into Vec //cargo run -- -n 100 let arg = args!(); assert_eq!(arg,vec![format!("-n"),format!("100")]);

//get input and into String let s = input!(); println!("{:?}",s);

//power of two f64 number let p = powf!(2.,2.); assert_eq!(p,4.0);

//split a:&str by b:&str and collect into Vec
let s = splittovec!("aa.bb","."); assert_eq!(s,vec![format!("aa"),format!("bb")]);

// read .csv file and return Vec> let s = readcsv!("./data.csv"); asserteq!(s,vec![vec![format!("a"), format!("b"), format!("c")],vec![format!("1"), format!("2"), format!("3")],vec![format!("10"), format!("20"), format!("30")]]);

//removefileorfolder!() used to remove file or folder //type &str path removefileorfolder!("./demo.txt"); removefileor_folder!("./target");

//return sorted vec // type can be Vec Vec Vec Vec Vec Vec Vec let s1 = sorted!(vec![1.2, 2.6, 0.2]); let s2 = sorted!(vec![8, 1i128, 5i128]); asserteq!(s1,vec![0.2,1.2,2.6]); asserteq!(s2,vec![1,5,8]);

// return sorted and deduped new Vec // type can be Vec Vec Vec Vec Vec Vec Vec let s1 = dedupedsorted!(vec![1.2, 1.2,2.6, 0.2]); let s2 = dedupedsorted!(vec![8, 1i128, ,8,5i128]); asserteq!(s1,vec![0.2,1.2,2.6]); asserteq!(s2,vec![1,5,8]);

//parse Vec element to f64, //need a Vec<&str>,and parse type //return Vec let v1: Vec = vecelementparse!(vec!["15.", "2.9"], f64); let v2: Vec = vecelementparse!(vec!["15", "2"], i128); let v3: Vec = vecelementparse!(vec![".15", ".2"], f32); asserteq!(vec![15.0, 2.9], v1); asserteq!(vec![15, 2], v2); assert_eq!(vec![0.15, 0.2], v3);

//vecelementtostring!() used to // convert vec element to String, // type can be Vec Vec Vec Vec Vec,Vec<&str> // return Vec let v1 = vecelementtostring!(vec!["15.", "2.9"]); let v2 = vecelementtostring!(vec![15, 2]); let v3 = vecelementtostring!(vec![0.15, 0.2]); asserteq!(vec!["15.", "2.9"], v1); asserteq!(vec!["15", "2"], v2); assert_eq!(vec!["0.15", "0.2"], v3); ```

rust //snail_sort!() return the array elements arranged from outermost //elements to the middle element, traveling clockwise.n x n //type can be Vec<Vec<T>> //return Vec<T>

```rust let v1 = snailsort!(vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]]); let v2 = snailsort!(vec![vec![1.1, 2.1, 3.1],vec![4.1, 5.1, 6.1],vec![7.1, 8.1, 9.1]]); asserteq!(vec![1, 2, 3, 6, 9, 8, 7, 4, 5], v1); asserteq!(vec![1.1, 2.1, 3.1, 6.1, 9.1, 8.1, 7.1, 4.1, 5.1], v2);

// multiplymatrix!() return the mutiply result of two matrix // take two matrix and type can be Vec> // return Vec> let m1: Vec> = vec![vec![1.0, 2.0], vec![1.0, 2.0]]; let m2: Vec> = vec![vec![0.0, 0.0], vec![0.0, 0.5]]; let mulresult = multiplymatrix!(&m2, &m1); asserteq!(mul_result, vec![[0.0, 0.0], [0.5, 1.0]]);

// vecelementremove!() used to // find the element fist position and remove // if not fond the element return original vec // type can be Vec Vec Vec Vec Vec,Vec<&str> // return return the same type let v1 = vecelementremove!(vec!["15.", "2.9"], "2.9"); let v2 = vecelementremove!(vec![15, 2, 3, 2], 2); let v3 = vecelementremove!(vec![0.15, 0.2, 0.2], 0.2); asserteq!(vec!["15."], v1); asserteq!(vec![15, 3, 2], v2); assert_eq!(vec![0.15, 0.2], v3);

// vecelementremoveall!() used to // find the element all position and remove // if not fond the element return original vec // type can be Vec Vec Vec Vec Vec,Vec<&str> // return return the same type let v1 = vecelementremoveall!(vec!["15.", "2.9", "0.9", "2.9", "2.9"], "2.9"); asserteq!(vec!["15.", "0.9"], v1); let v2 = vecelementremoveall!(vec![15, 2, 3, 2], 2); asserteq!(vec![15, 3], v2); let v3 = vecelementremoveall!(vec![0.15, 0.2, 1.0, 0.2], 0.3); assert_eq!(vec![0.15, 0.2, 1.0, 0.2], v3);

//vecelementpositionall!() used to find element position and collect into Vec let v1 = vecelementpositionall!(vec![1, 2, 5, 3, 6, 2, 2], 2); assert_eq!(v1, vec![1, 5, 6]);

// vecslice!() used to // slice vec by range // type can be Vec Vec Vec Vec Vec,Vec<&str> // and need a range [a..b]=> a to b ,[..]=>all // return return the same type let v1 = vecslice!(vec![1.2, 1.5, 9.0], [..2]); let v2 = vecslice!(vec![1, 1, 9, 90, 87, 0, 2], [4..6]); let v3 = vecslice!(vec![1.2, 1.5, 9.0], [..]); let v4 = vecslice!(vec![1.2, 1.5, 9.0], [1..]); let v5 = vecslice!(vec!["1", "2", "3", "4", "5"], [2..5]); let v6 = vecslice!(vec!["1".tostring(),"2".tostring(),"3".tostring()], [1..]); asserteq!(v1, vec![1.2, 1.5]); asserteq!(v2, vec![87, 0]); asserteq!(v3, vec![1.2, 1.5, 9.0]); asserteq!(v4, vec![1.5, 9.0]); asserteq!(v5, vec!["3", "4", "5"]); asserteq!(v6,vec!["2".tostring(),"3".tostring()]);

//vecelementclone!() used to when occure //cannot move out of index of Vec<String> //move occurs because value has type String, which does not implement the Copy trait let v1 = vecelementclone!(vec!["15.", "2.9"], 1); let v2 = vecelementclone!(vec![15, 2, 3, 2], 2); let v3 = vecelementclone!(vec![0.15, 0.2, 0.2], 0); let v4 = vecelementclone!(vec![format!("1"),format!("2"),format!("3"),format!("4"),format!("5")],4); asserteq!("2.9", v1); asserteq!(3, v2); asserteq!(0.15, v3); asserteq!(format!("5"), v4);

//vecelementconvert!() used convert vec elements type let v1: Vec = vecelementconvert!(vec![1, 2], f64); let v2: Vec = vecelementconvert!(vec![1.0, 2.0], i32); let v3: Vec = vecelementconvert!(vec![1.0, 2.0], i128); let v4: Vec = vecelementconvert!(vec![1usize, 2usize], i32); let v5: Vec = vecelementconvert!(vec![0.15, 2.0], i64); asserteq!(v1, vec![1.0, 2.0]); asserteq!(v2, vec![1, 2]); asserteq!(v3, vec![1, 2]); asserteq!(v4, vec![1, 2]); assert_eq!(v5, vec![0, 2]);

// vectype!() used to get vec type // return format!("{}",type); asserteq!(vectype!(vec![0.2f64]), format!("Vec")); asserteq!(vectype!(vec![0.2f32]), format!("Vec")); asserteq!(vectype!(vec![2i32]), format!("Vec")); asserteq!(vectype!(vec![2i128]), format!("Vec")); asserteq!(vectype!(vec![2isize]), format!("Vec")); asserteq!(vectype!(vec![2_usize]), format!("Vec"));

// expr return max value let remax = max!(1, 2); asserteq!(re_max,2);

// expr return min value let remin = min!(1, 2, 2, 5, 4, 6); asserteq!(re_max,1);

//convert binary string to decimal let d1 = binarytodecimal!("01101",i128); asserteq!(d1,13i128); let d2 = binarytodecimal!("00000000000010100110001",i64); asserteq!(d2,1329i64); let d3 = binarytodecimal!("000011",i32); asserteq!(d3,3i32); let d4 = binarytodecimal!("000101",i16); asserteq!(d4,5i16); let d5 = binarytodecimal!("001001",i8); asserteq!(d5,9i8);

// get memoryaddress let d1 = binarytodecimal!("01101",i128); println!("{:?}",memoryaddress!(d1));//0x7ffcac734f08

// merge two vec return merged vec let v1 = vecmerge!(vec![0, 1, 2], vec![5, 6, 7]); asserteq!(vec![0, 1, 2, 5, 6, 7],v1); let v2 = vecmerge!(vec![0., 1., 2.], vec![5., 6., 7.]); asserteq!(vec![0., 1., 2., 5., 6., 7.],v2);

// take size of elements and return a new vec let v1 = vecelementtake!(vec![0, 1, 2],2); assert_eq!(vec![0,1],v1);

// zip two vec elements in tuple let v1 = veczip!(vec![0, 1, 2],vec![0, 1, 2]); asserteq!(vec![(0,0),(1,1),(2,2)],v1);

// enumerate all indexs and elements collect tuple of vec let v1 = vecenumerate!(vec![12, 11, 20]); asserteq!(vec![(0,12),(1,11),(2,20)],v1);

// sort vec and return sorted vec let v1 = vecsort!(vec![10, 2, 3]); asserteq!(vec![2,3,10],v1); let v2 = vecsort!(vec![1.8, 2.5, 0.3]); asserteq!(vec![0.3,1.8,2.5],v2);

// has stable rust compiler return bool let v1 = hasstablecompiler!(); assert_eq!(v1, false);

// has nightly rust compiler return bool let v1 = hasnightlycompiler!(); assert_eq!(v1, true);

// run command command!("ls -la");
command!("dust");
command!("lsd");
```