構造
配列 連結リスト
append
R5RS
(append list_1 list_2 ... list_n) - リストの連結
(let* ((a (list 1 2 3)) (b (list 4 5)) (c (append a b))) (set-car! (list-tail c 2) 'x) (set-car! (list-tail c 3) 'y) (values a b c)) => (1 2 3) (y 5) (1 2 x y 5)
(append! list_1 list_2 ... list_n) - リストの連結
list1 ... list_n-1 が破壊される場合がある。
list1 ... list_n-1 が破壊される場合がある。
(define x (list 'a 'b 'c)) (set! x (append! x '(1 2 3)) x => (a b c 1 2 3)
concat
javascript
indexOf
iota
srfi
srfi-1: (iota count [start] [step]) - 等間隔の数値をもつリスト
(start start+step ... start+(count-1)*step)
(iota 6) => (0 1 2 3 4 5) (iota 3 5 0.5) => (5 5.5 6)
join
lastIndexOf
length
list
list-ref
R5RS
(list-ref list index)
(list-ref '(a b c d) 2) => c
memcpy
C
#include <string.h> memcpy (void *dest, const void *src, size_t n);
pop
Perl
pop array - Pops and returns the last value of the array, shortening the array by one element.
@a = (1, 2, 3, 4); pop (@a) => 4 "@a" => 1 2 3
Gauche
Macro: (pop! place) - (car place) を返し、place に (cdr place) をセットする
(set! x '(1 2 3 4)) (pop! x) => 1 x => (2 3 4)
Perlのshiftに近い
push
reverse
shift
Perl
shift array - 配列の先頭の値を除去し、その値を返す。
配列が空の場合、未定義値が返る。definedで検出。
配列が空の場合、未定義値が返る。definedで検出。
slice
sort
splice
split
subseq
Common Lisp
Gauche
(use gauche.sequence) (subseq '(a b c d e) 2 2) => (c d)
unshift
Perl
unshift array, list - Prepends list to the front of the array, and returns the new number of elements in the array.
@a = (1, 2); unshift (@a, 3, 4, 5) => 5 "@a" => 3 4 5 1 2