1
this 질문 이후에 F #에서 두 개의 지연 목록을 병합하려고합니다. 원래 두 목록 일치에 대해 썼습니다. 수정 한 내용은 다음과 같습니다.F #의 LazyList와의 패턴 일치 오류
let rec printLazyList (l1:LazyList<int>) (l2:LazyList<int>) =
match (l1, l2) with
| t, s when t |> LazyList.isEmpty && s |> LazyList.isEmpty -> printfn "";
| t , LazyList.Cons(h2,t2) when t |> LazyList.isEmpty -> printf "%d " h2
let a = LazyList.empty
printLazyList a t2
| LazyList.Cons(h1,t1), s when s |> LazyList.isEmpty -> printf "%d " h1
let b = LazyList.empty
printLazyList t1 b
| LazyList.Cons(h1,t1), LazyList.Cons(h2,t2) -> if h1 = h2 then
printf "%d " h1
printLazyList t1 t2
elif h1 < h2 then
printf "%d " h1
printLazyList t1 l2
else
printf "%d " h2
printLazyList l1 t2
문제는 출력하지 않는 것입니다. 어떤 조건도 만족하지 않습니다 (패턴 일치가 끝나면 |_,_ printfn "nothing matches"
을 넣어 확인하십시오.) cons
과 LazyList의 차이점은 보통 F # 목록의 ::
대 정상적인 목록에서 작동했기 때문입니다. (참조 위의 링크).
이 다시 정말 n00b 질문 인 경우 죄송합니다. 많은이 있기 때문에 FP가
Nil
대신isEmpty
을 사용하고 재구성하여 몇 가지 정리를했다). 주로 청소를 해줘서 고마워, 선생님이 내가 실험실에서 그것을 어떻게 놓쳤는 지 안다! – AruniRC