ãªã¹ã
ãªã¹ãã¯ãã¼ã¿ãæ¬å¼§ã§ããã£ããã®ããªã¹ãã«ã¯æç¶ãã¨ãã¼ã¿ãããããã¼ã¿ã¯'ï¼ã¯ã©ã¼ã)ããªã¹ãã®åã«ã¤ããã
(+ 1 2) ; æç¶ãã®ãªã¹ããè©ä¾¡ããã¨3ãè¿ãã '(1 2 3) ; ãã¼ã¿ã®ãªã¹ããè©ä¾¡ããã¨(1 2 3)ãè¿ãã
ãªã¹ãã®åºæ¬æä½
- ãªã¹ãã®å é ã®è¦ç´ ãèªãcar
- ãªã¹ãã®å é 以å¤ã®ã®è¦ç´ ãè¿ãcdr
- å é è¦ç´ ã¨ãæ®ãã®è¦ç´ ãããªããªã¹ãããã£ã¤ããcons
gosh> (car '(1 2 3)) 1 gosh> (cdr '(1 2 3)) (2 3) gosh> (cons 1 '()) (1)
空ãªã¹ãã«carã¨cdrãå®è¡ããã¨ã¨ã©ã¼ã
gosh> (car '()) *** Error: pair required, but got () gosh> (cdr '()) *** ERROR: pair required, but got ()
consã®ç¬¬ï¼å¼æ°ã«ãªã¹ã以å¤ã渡ãã¨ããããªã¹ããä½æãããã
gosh> (cons 1 2) (1 . 2)
- å¼æ°ã空ãªã¹ããã©ããå¤å®ããæç¶ãnull?
- å¼æ°ã空ãªã¹ãã§ãªããªã¹ããã©ããå¤å®ããæç¶ãpair?
gosh> (null? '()) #t gosh> (null? '(1 2)) #f gosh> (pair? '()) #f gosh> (pair? '(1 2)) #t
ã¨ãããã¨ã§ãä»æ¥ã¯6.2ã¾ã§ã
çå1.carã¨cdrã¯ããªãã¨èªããã ããï¼
çå2.ããããªã¹ãã£ã¦ä½ã ï¼æ¬ã«ããã¨ãè¦ç´ ã®æå¾ã空ãªã¹ãã§ãªããªã¹ããããããªã¹ãã¨ãã£ã¦ããããã ãã»ã»ã
çå3.Gauche(Scheme)ã«ã¯äºç´èªããªãã¨ãããã¨ã ããæ¡å¼µæ§ãé«ã¾ããããªã®ã ãããã