0

私は次の機能を持っています:

getcountof(x,l::ls) = 
if x=l then  (1 + getcountof(x,ls))
else getcountof(x,ls)
|getcountof(x,[]) = 0;

誰かが私に何が悪いのか教えてもらえますか? エラーが発生します:

stdIn:1.2-1.17 Error: syntax error: deleting  ELSE ID
stdIn:1.22-20.12 Error: syntax error: deleting  RPAREN BAR ID
4

1 に答える 1

1

fun定義の最初からキーワードが抜けています!

代わりにこれを試してください:

fun getcountof(x,l::ls) = 
     if x=l then  (1 + getcountof(x,ls))
     else getcountof(x,ls)
  | getcountof(x,[]) = 0;

これは、Haskell に詳しい人にとっては罠です。

于 2012-10-30T22:44:39.067 に答える