별의 공부 블로그 🧑🏻‍💻

🗒️ Source Code/LISP (CL) (6)

728x90
  1. 2017.06.08 Block's World

    ;;;; Block's World;; ;;;; Global Variables;; (defstruct blocks (name nil) (color nil) (ison 'table) (isunder nil)) (defvar *blocks*) ;;;; Main;; (defun start-world () (setf *blocks* nil)) (defun new-block (name color) (push (make-blocks :name name :color color) *blocks*)) (defun get-block (name) (dolist (x *blocks* nil) (if (equal name (blocks-name x)) (return x)))) (defun clear-top? (name) (if ..

  2. 2017.05.31 samesetp

    (defun samesetp (lis1 lis2) (if (and (not (null lis1)) (not (null lis2))) (let ((x (first lis1)) (y (first lis2))) (cond ((and (listp x) (listp y)) (and (samesetp x y) (samesetp (rest lis1) (rest lis2)))) (t (and (eq x y) (samesetp (rest lis1) (rest lis2)))))) (= (length lis1) (length lis2)))) (defun samesetp (lis1 lis2) "Another Version of samesetp." (if (null lis1) (null lis2) (let ((x (remove..

  3. 2017.05.30 Tic Tac Toe Game

    ;; Defining global varaibles and constants (defconstant One 1) ;; human(defconstant TheOther 10) ;; computer (defvar *Opponent* One)(defvar *Computer* TheOther) (defvar *Triplets* '((1 2 3) (4 5 6) (7 8 9) ;; Horizontal Line (1 4 7) (2 5 8) (3 6 9) ;; Vertical Line (1 5 9) (3 5 7))) ;; Diagonal Line ;; Main ;; Initialization: Creating a board (defun makeBoard () (list 'Board 0 0 0 0 0 0 0 0 0)) ..

  4. 2017.05.18 입출력 (INPUT / OUTPUT)

    ;; INPUT/OUTPUT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; WITH-OPEN-FILE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Opening file for output ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun get-tree-data () (with-open-file (stream "timber.txt") (let* ((tree-loc (read stream)) (tree-table (read stream)) (num-trees (read str..

  5. 2017.05.16 순환 (Recursion)

    ;; Recursion (defun anyoddp (x) (cond ((null x) nil) ((oddp (first x)) t) (t (anyoddp (rest x))))) (defun fact (n) (cond ((zerop n) 1) (t (* n (fact (- n 1)))))) (defun count-slices (loaf) (cons ((null loaf) 0) (t (+ 1 (count-slices (rest loaf)))))) ;; Double-Test Tail Recursion (defun func (x) (cond (end-test-1 end-value-1) (end-test-2 end-value-2) (t (func reduced-x)))) (defun anyoddp (x) (con..

  6. 2017.04.21 Checking whether an input element is a number or not with using DO macro. (Infinite Loop)

    (defun read-a-number () (do ((answer nil)) (nil) ; This is necessary to make Infinite Loop function. (format t "~&Please type a number: ") (setf answer (read)) (if (numberp answer) (return answer) (format t t "~&Sorry, ~S is not a number. Try again." answer)))) A Program which checks whether the input number is a number or not by using DO macro. If the input number is not a number, the program p..

728x90


📖 Contents 📖