Re: [q-lang-users] Special values or failing functions
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2007-05-17 20:46:31
|
Alexander Nickolsky wrote: > len [] = 0; > len [[H|Hs]|T] = _FAIL_; > len [H|T] = 1+len T; > > so semantics of _FAIL_ would be : rewrite the current match with > itself and return. > So, 'fail' applies to the left side, but _FAIL_ applies to the right side. I don't grok this last sentence. Should 'len [[1,2],3]' return 'len [[1,2],3]' itself, or _FAIL_, or what? And what should 'len [1,[2,3]]' return? > no matter how you call it - reject, normal, agree, refuse - which > strangely means the same. reject sounds like a worthy candidate. Or we could just use _FAIL_, it's a valid function identifier. > X+Y = Y+X; // commutative rule > will not work. No, it just loops. In a CAS, you'd have to add a qualifying condition there which makes sure that terms are ordered in some way. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |