I've been doing some calculations on genome mutations and I've been finding myself doing a lot of
if(zero_type(foo) && zero_type(bar) ... && zero_type(gonk)) ...
when checking up on user input that is used to index mappings.
Could you explain some more why you land at testing a lot of zero_types? I didn't quite get the reason...
/ Mirar
Previous text:
2003-09-28 01:39: Subject: zero_type();
I've been doing some calculations on genome mutations and I've been finding myself doing a lot of
if(zero_type(foo) && zero_type(bar) ... && zero_type(gonk)) ...
when checking up on user input that is used to index mappings. So... I was wondering if it is safe to do this? Or perhaps - even make zero_type() do this by default?
int zero_types(mixed ... tt) { if(arrayp(tt)) { foreach(tt, mixed t) if(zero_type(t)) return 1; return 0; }
return zero_type(tt); }
It seems to work alright - but I feel that this might perhaps in some way, I havent thought of, dangerous.
mapping m=(["A":1]); zero_types(m["A"]);
(9) Result: 0
zero_types(m["R"]);
(10) Result: 1
zero_types(m["R"],m["A"]);
(11) Result: 1
zero_types(m["A"],m["A"]);
(12) Result: 0
zero_types(m["A"],m["R"]);
(13) Result: 1
zero_types(m["R"],m["R"]);
(14) Result: 1
/ Peter Lundqvist (disjunkt)