|
|
이전 주제 보기 :: 다음 주제 보기 |
글쓴이 |
메시지 |
장민석
가입: 2006년 9월 5일 올린 글: 165
|
올려짐: 2006년11월17일 19:51 주제: 보물섬 결과를 정렬해야 하나요? |
|
|
결과를 크기순으로 정렬해야 하나요?
집합이니까 굳이 정렬을 하지 않아도 될 것 같습니다만,,
음...실은 정렬하려면 좀 복잡해서 말입니다.;; |
|
위로 |
|
|
박대준
가입: 2005년 10월 7일 올린 글: 245
|
올려짐: 2006년11월18일 0:44 주제: |
|
|
정렬하시면 더 좋지만, 그렇게 하지 않으셔도 상관없습니다.
장민석 씀: | 음...실은 정렬하려면 좀 복잡해서 말입니다.;; |
기본 라이브러리로 제공되는 다음 함수들을 사용하시면, 좀 더 간편하게 정렬할 수 있을 것으로 보입니다.
인용: | val sort : ('a -> 'a -> int) -> 'a list -> 'a list
---------------------------------------------------
Sort a list in increasing order according to a comparison function. The comparison function must return 0 if it arguments compare as equal, a positive integer if the first is greater, and a negative integer if the first is smaller. For example, the compare function is a suitable comparison function. The resulting list is sorted in increasing order. List.sort is guaranteed to run in constant heap space (in addition to the size of the result list) and logarithmic stack space.
The current implementation uses Merge Sort and is the same as List.stable_sort. |
인용: | val compare : 'a -> 'a -> int
----------------------------------
compare x y returns 0 if x=y, a negative integer if x<y, and a positive integer if x>y. The same restrictions as for = apply. compare can be used as the comparison function required by the Set and Map modules. |
|
|
위로 |
|
|
|
|
새로운 주제를 올릴 수 없습니다 답글을 올릴 수 없습니다 주제를 수정할 수 없습니다 올린 글을 삭제할 수 없습니다 투표를 할 수 없습니다
|
Powered by phpBB 2.0.21-7 (Debian) © 2001, 2005 phpBB Group Translated by kss & drssay
|