[erlang-questions] View patterns

ok <>
Thu Jul 26 05:12:56 CEST 2007


I made a mistake.

     np(K, X) when integer(X), integer(K), X >= K ->
         {X};              %%%% HERE
     np(_, _) ->
         false.

should of course be

     np(K, X) when integer(X), integer(K), X >= K ->
         {X - K};
     np(_, _) ->
         false.

Fix that and all is well.

The real trick with view patterns is to compile them so that you
do not do too much repeated work.




More information about the erlang-questions mailing list