2013/01/26 4

(최대공약수 구하기) while... 반복문 예제 for OCaml

소스 파일명: testWhile.ml (* * Filename: testWhile.ml * * Purpose: Example using the while loop syntax * while .... * * Execute: ocaml testWhile.ml -200 300 * * Or * * Compile: ocamlc -o testWhile.exe testWhile.ml * Execute: testWhile -200 300 *) (* 사용법 표시 *) let printUsage() = Printf.printf "Using: testWhile.py [integer1] [integer2]\n"; Printf.printf "This finds the greatest common divisor of the gi..

구구단 출력 예제 for OCaml

OCaml 언어는 함수형 언어이면서도 명령형 언어의 특징을 대부분 가지고 잇다. 따라서 보통의 for 구문을 쓸 수도 있고, 재귀호출 함수릉 만들어 쓸 수도 있다. 아래의 소스에서 함수 printDan 은 보통의 for 구문을 쓴 것이고 함수 printAnotherDan 은 재귀호출 함수를 쓴 것이다. 소스 파일명: forTest.ml ------------------------------[소스 시작] (* Filename: forTest.ml Execute: ocaml forTest.ml Or Compile: ocamlc -o forTest forTest.ml Execute: ./forTest Or Compile: ocamlc -o forTest.exe forTest.ml Execute: forTest..