mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Add files via upload
This commit is contained in:
parent
290e2267f4
commit
593b46cb91
1 changed files with 3 additions and 3 deletions
|
@ -21,7 +21,6 @@
|
||||||
// value = value to set the keyword to
|
// value = value to set the keyword to
|
||||||
// grow = Set to true to allow structure to grow, or false for new keywords to generate an error. Default: true
|
// grow = Set to true to allow structure to grow, or false for new keywords to generate an error. Default: true
|
||||||
function struct_set(struct, keyword, value=undef, grow=true) =
|
function struct_set(struct, keyword, value=undef, grow=true) =
|
||||||
let(aa=echo(struct=struct, keyword=keyword, value=value, grow=grow))
|
|
||||||
!is_list(keyword) ?
|
!is_list(keyword) ?
|
||||||
let(ind=search([keyword],struct,1,0)[0])
|
let(ind=search([keyword],struct,1,0)[0])
|
||||||
(ind==[] ? assert(grow,str("Unknown keyword \"",keyword))
|
(ind==[] ? assert(grow,str("Unknown keyword \"",keyword))
|
||||||
|
@ -32,7 +31,7 @@ function struct_set(struct, keyword, value=undef, grow=true) =
|
||||||
function _parse_pairs(spec, input, grow=true, index=0, result=undef) =
|
function _parse_pairs(spec, input, grow=true, index=0, result=undef) =
|
||||||
assert(len(input)%2==0,"Odd number of entries in [keyword,value] pair list")
|
assert(len(input)%2==0,"Odd number of entries in [keyword,value] pair list")
|
||||||
let( result = result==undef ? spec : result)
|
let( result = result==undef ? spec : result)
|
||||||
index == len(input) ? result : let(dd=echo(dd=spec, input, grow,index, result))
|
index == len(input) ? result :
|
||||||
_parse_pairs(spec,input,grow,index+2,struct_set(result, input[index], input[index+1],grow));
|
_parse_pairs(spec,input,grow,index+2,struct_set(result, input[index], input[index+1],grow));
|
||||||
|
|
||||||
// Function: struct_remove()
|
// Function: struct_remove()
|
||||||
|
@ -56,7 +55,8 @@ function struct_remove(struct, keyword) =
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// struct = input structure
|
// struct = input structure
|
||||||
// keyword = keyword whose value to return
|
// keyword = keyword whose value to return
|
||||||
function struct_val(struct,keyword) =
|
function struct_val(struct,keyword) =
|
||||||
|
assert(is_def(keyword),"keyword is missing")
|
||||||
let(ind = search([keyword],struct)[0])
|
let(ind = search([keyword],struct)[0])
|
||||||
ind == [] ? undef : struct[ind][1];
|
ind == [] ? undef : struct[ind][1];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue