List와 같은 F # 모듈에 몇 가지 편리한 메소드를 추가했습니다.F # List 모듈 확장하기
type Microsoft.FSharp.Collections.FSharpList<'a> with //'
static member iterWhile (f:'a -> bool) (ls:'a list) =
let rec iterLoop f ls =
match ls with
| head :: tail -> if f head then iterLoop f tail
| _ ->()
iterLoop f ls
내가 돌연변이를 추가 할 수 있는지 궁금한가요? List가 불변이므로 List에 유형을 변경할 수있는 메소드를 추가하는 것이 좋습니다. 이 같은.
type Ref<'a when 'a :> Microsoft.FSharp.Collections.FSharpList<'a> > with //'
member this.AppendMutate element =
this := element :: !this
또는 대체 할 수있는 일반적인 방법이 있습니까?