From 3b1d5672194c3a36d78a39331988142e3c4572d2 Mon Sep 17 00:00:00 2001 From: RonaldoCMP Date: Fri, 31 Jul 2020 01:03:32 +0100 Subject: [PATCH] Revert "Minor edits in in_list" This reverts commit 74cc246c75b97d2203544841ed5eaf717b59782b. --- arrays.scad | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arrays.scad b/arrays.scad index 8f8cb45..365649a 100644 --- a/arrays.scad +++ b/arrays.scad @@ -108,16 +108,14 @@ function slice(list,start,end) = // Arguments: // val = The simple value to search for. // list = The list to search. -// idx = If given, searches the given subindex for matches for `val`. +// idx = If given, searches the given subindexes for matches for `val`. // Example: // in_list("bar", ["foo", "bar", "baz"]); // Returns true. // in_list("bee", ["foo", "bar", "baz"]); // Returns false. // in_list("bar", [[2,"foo"], [4,"bar"], [3,"baz"]], idx=1); // Returns true. function in_list(val,list,idx=undef) = - assert( is_list(list) && (is_undef(idx) || is_finite(idx)), - "Invalid input." ) let( s = search([val], list, num_returns_per_match=1, index_col_num=idx)[0] ) - s==[] || s==[[]] ? false + s==[] || s[0]==[] ? false : is_undef(idx) ? val==list[s] : val==list[s][idx];