"함수 array count values()"의 두 판 사이의 차이

잔글 (Jmnote 사용자가 Unique count 문서를 함수 array count values() 문서로 옮겼습니다)
(차이 없음)

2015년 8월 30일 (일) 00:36 판

uniq -c
array_count_values

1 Bash

ARR=(1 "hello" 1 "world" "hello")
for VALUE in "${ARR[@]}"; do
	echo $VALUE
done | sort | uniq -c
#      2 1
#      2 hello
#      1 world

2 PHP

$array = array(1, 'hello', 1, 'world', 'hello');
print_r(array_count_values($array));
// Array
// (
//     [1] => 2
//     [hello] => 2
//     [world] => 1
// )

3 Python

import collections
lst = [1, 'hello', 1, 'world', 'hello']
print( collections.Counter(lst) )
# Counter({1: 2, 'hello': 2, 'world': 1})

4 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}