-1
나는 이 운동에 대한 문제!목록에서 [ai, ..., ai, ai +1, ..., an] 목록에 [ai + 1, ..., an, a1, .... ai] OCaml
내 아이디어는 두 가지 기능을 생성하는 것이다
- 가 제 기능을 입력으로 제 기능의 결과를 고려하여리스트
[ai + 1, ..., an]
- 번째 함수를 생성하고 결과를 반환
[ai + 1, ..., an, a1, ..., ai]
문제는 방금 Ocaml로 프로그래밍을 시작했는데 사용법을 잘 이해하지 못하고 있다는 것입니다. 그래서 나는 해결 방법을 모른다는 몇 가지 오류가 있습니다. 내 코드는 이것이다 :
let rec produceprima l i =
let rec produceprima_aux l i acc=
let rec aux l i acc l1 =
match l with
[]-> []
|x::y -> if(acc>i) then aux y i acc+1 [email protected][x]
else aux y i acc+1 l1
in aux l i acc l1
in produceprima_aux l i acc;;
let rec produceseconda l i =
let rec produceseconda_aux l i acc=
let rec aux l i acc l1 =
match l with
[]-> []
|x::y -> if(acc<=i) then aux y i acc+1 [email protected][x]
in aux l i acc l1
in produceseconda_aux l i acc;;
첫 번째 함수의 오류는 다음과 같습니다
Error: This expression has type 'a -> 'b list
but an expression was expected of type int
두 번째 기능은 내가 시도해야하지만, 확실히이 오류를!
정말 고마워요. 시도해 봤어! 확실히 나는 튜토리얼을 볼 것이다! –