Monday, January 19, 2009

Ch2, Ex5

Only thing to remember is that clauses are tested sequentially starting with the first clause. Execution passes to next clause only if all the clauses before it failed to match with input pattern. With this its fairly trivial to think the answers, but I'm giving them here anyway..

{Test [b c a]} % 'case'(4)
{Test f(b(3))} % 'case'(5)
{Test f(a)} % 'case'(2)
{Test f(a(3))} % 'case'(5)
{Test f(d)} % 'case'(5)
{Test [a b c]} % 'case'(1)
{Test [c a b]} % 'case'(4)
{Test a|a} % 'case' (1)

No comments:

Post a Comment