1
私はSoftware Foundationsを読み、その問題を解決しています。これは私が定義しようとしている定義のいずれかです。ヘルパー関数を使用しない定義関数
Fixpoint split {X Y : Type} (l : list (X*Y)) : (list X) * (list Y)
基本的にはハスケルのunzip
バージョンです。
は、私はこのようにそれを実装:
Fixpoint split2 {X Y : Type} (l : list (X*Y)) (g :(list X) * (list Y))
: (list X) * (list Y) :=
match l with
| [] => g
| (x,y)::xs => split2 xs ((fst g) ++ [x],(snd g) ++ [y])
end.
Fixpoint split {X Y : Type} (l : list (X*Y))
: (list X) * (list Y) :=
split2 l ([],[]).
I持っている二つの質問:
- それは
split2
このようなヘルパー関数を使用せずにsplit
を定義することは可能ですか? - Coqにはwhere節(Haskellのような)がありますか?