(* lengthOfList[list] : list の長さを求める list : 長さを求めるリスト ( cf. Length ) *) lengthOfList[{}] := 0 lengthOfList[list_] := lengthOfList[Rest[list]] + 1 (* lengthOfList[{}] lengthOfList[{a,b,c}] *) (* lengthOfList[list_] := If[ list == {}, 0, lengthOfList[Rest[list]] + 1 ] *) (* findMember[list,member] : list の中の member の位置を探す list : 要素を探すリスト ( cf. Length ) *) findMember[list_,member_] := findMember[list,member,1] findMember[{},member_,pos_] := -1 findMember[list_,member_,pos_] := If[ First[list] == member, pos, findMember[Rest[list],member,pos + 1] ] (* findMember[{"a","b","c","d"}, "c"] findMember[{"a","b","c","d"}, "x"] *)