1
0
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:
Justin Lin 2020-01-26 16:50:52 +08:00
parent e82545fe37
commit c16d43669e
3 changed files with 20 additions and 16 deletions

View 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);

View File

@ -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);

View File

@ -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 ====");