Added strings.scad to std.scad

This commit is contained in:
Revar Desmera 2020-03-13 20:07:24 -07:00
parent f7578b4ba3
commit c1e3f5d60a
3 changed files with 5 additions and 11 deletions

View file

@ -531,19 +531,12 @@ function attachment_is_shown(tags) =
assert(!is_undef($tags_shown)) assert(!is_undef($tags_shown))
assert(!is_undef($tags_hidden)) assert(!is_undef($tags_hidden))
let( let(
tags = _str_char_split(tags, " "), tags = str_split(tags, " "),
shown = !$tags_shown || any([for (tag=tags) in_list(tag, $tags_shown)]), shown = !$tags_shown || any([for (tag=tags) in_list(tag, $tags_shown)]),
hidden = any([for (tag=tags) in_list(tag, $tags_hidden)]) hidden = any([for (tag=tags) in_list(tag, $tags_hidden)])
) shown && !hidden; ) shown && !hidden;
function _str_char_split(s,delim,n=0,acc=[],word="") =
(n>=len(s))? concat(acc, [word]) :
(s[n]==delim)?
_str_char_split(s,delim,n+1,concat(acc,[word]),"") :
_str_char_split(s,delim,n+1,acc,str(word,s[n]));
// Function: reorient() // Function: reorient()
// //
// Usage: // Usage:
@ -1054,7 +1047,7 @@ module recolor(c)
// } // }
module hide(tags="") module hide(tags="")
{ {
$tags_hidden = tags==""? [] : _str_char_split(tags, " "); $tags_hidden = tags==""? [] : str_split(tags, " ");
children(); children();
} }
@ -1071,7 +1064,7 @@ module hide(tags="")
// } // }
module show(tags="") module show(tags="")
{ {
$tags_shown = tags==""? [] : _str_char_split(tags, " "); $tags_shown = tags==""? [] : str_split(tags, " ");
children(); children();
} }

View file

@ -16,6 +16,7 @@ include <edges.scad>
include <common.scad> include <common.scad>
include <errors.scad> include <errors.scad>
include <arrays.scad> include <arrays.scad>
include <strings.scad>
include <vnf.scad> include <vnf.scad>
include <math.scad> include <math.scad>

View file

@ -8,7 +8,7 @@
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,184]; BOSL_VERSION = [2,0,185];
// Section: BOSL Library Version Functions // Section: BOSL Library Version Functions