Skip to content

Instantly share code, notes, and snippets.

@MarkShulhin
Created September 18, 2017 18:29
Show Gist options
  • Save MarkShulhin/b721d625b1007ef725480733b351a134 to your computer and use it in GitHub Desktop.
Save MarkShulhin/b721d625b1007ef725480733b351a134 to your computer and use it in GitHub Desktop.
Scheme lab 2
#lang scheme
(define myexp '(((a.1) b (c.2) D) (((e.3) 4 (5.6))(f.7))
((9.8) 29 h ((10.I) (11.J) K 12))
(((13.L) (d (14.m))) (15 (n.16)))
((Q (17.18) ((p.19) r) 88) 20)
99 z))
(display "Количество елементов главного списка: ")
(length myexp)
;(car(cadaar(cdddr myexp))) = d
;(cdr(car(cddr(caar(cddddr myexp))))) = r
;(cadr(cddr(caar(cddddr myexp)))) = 88
(display "Новый список из е1, е2, е3 : ")
(cons (car(cadaar(cdddr myexp))) (cons (cdr(car(cddr(caar(cddddr myexp))))) (cons (cadr(cddr(caar(cddddr myexp)))) null)))
;разьеденить пару (1.2)
;(let ((x '(1 . 2)))
; (cons (car x) (cons (cdr x) null)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment