mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
use scad to reduce dependencies
This commit is contained in:
parent
e82545fe37
commit
c16d43669e
15
src/util/_impl/_split_str_impl.scad
Normal file
15
src/util/_impl/_split_str_impl.scad
Normal file
@ -0,0 +1,15 @@
|
||||
use <util/sub_str.scad>;
|
||||
|
||||
function _split_t_by(idxs, t) =
|
||||
let(leng = len(idxs))
|
||||
concat(
|
||||
[sub_str(t, 0, idxs[0])],
|
||||
[
|
||||
for(i = 0; i < leng; i = i + 1)
|
||||
sub_str(t, idxs[i] + 1, idxs[i + 1])
|
||||
]
|
||||
);
|
||||
|
||||
function _split_str_impl(t, delimiter) =
|
||||
len(search(delimiter, t)) == 0 ?
|
||||
[t] : _split_t_by(search(delimiter, t, 0)[0], t);
|
@ -8,16 +8,6 @@
|
||||
*
|
||||
**/
|
||||
|
||||
function _split_t_by(idxs, t) =
|
||||
let(leng = len(idxs))
|
||||
concat(
|
||||
[sub_str(t, 0, idxs[0])],
|
||||
[
|
||||
for(i = 0; i < leng; i = i + 1)
|
||||
sub_str(t, idxs[i] + 1, idxs[i + 1])
|
||||
]
|
||||
);
|
||||
|
||||
function split_str(t, delimiter) =
|
||||
len(search(delimiter, t)) == 0 ?
|
||||
[t] : _split_t_by(search(delimiter, t, 0)[0], t);
|
||||
use <_impl/_split_str_impl.scad>;
|
||||
|
||||
function split_str(t, delimiter) = _split_str_impl(t, delimiter);
|
@ -1,6 +1,5 @@
|
||||
include <unittest.scad>;
|
||||
include <util/sub_str.scad>;
|
||||
include <util/split_str.scad>;
|
||||
use <unittest.scad>;
|
||||
use <util/split_str.scad>;
|
||||
|
||||
module test_split_str() {
|
||||
echo("==== test_split_str ====");
|
||||
|
Loading…
x
Reference in New Issue
Block a user