Skip to content

Commit

Permalink
Day 2
Browse files Browse the repository at this point in the history
  • Loading branch information
alok committed Apr 19, 2020
1 parent 0fd68d9 commit c642cbe
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 0 deletions.
37 changes: 37 additions & 0 deletions program10.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;; loop

(setq *print-case* :capitalize)

;; (loop for x from 1 to 10
;; do
;; (print X))


;; or


;; (setq x 1)
;; (loop
;; (format t "~d ~%" x)
;; (setq x
;; (+ x 1))
;; (when
;; (> x 5)
;; (return X)))

;; -----------------------------------------------------
;; -----------------------------------------------------

;; list
;; (loop for x in '(Sandeep Shobit Sumit)
;; do
;; (format t "~s ~%" x))


;; -----------------------------------------------------
;; -----------------------------------------------------


;; dotimes
(dotimes (x 12)
(print x))
41 changes: 41 additions & 0 deletions program11.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(setq *print-case* :capitalize)

(format t "First Item: ~s ~%"
(car '
(superman batman aquaman flash joker)))
(format t "Items except First Item: ~s ~%"
(cdr '
(superman batman aquaman flash joker)))
(format t "Second Item: ~s ~%"
(cadr '
(superman batman aquaman flash joker)))
(format t "Third Item: ~s ~%"
(caddr '
(superman batman aquaman flash joker)))
(format t "Fourth Item: ~s ~%"
(cadddr '
(superman batman aquaman flash joker)))




(format t "IS IT A LIST? : ~s ~%"
(listp '
(superman batman aquaman flash joker)))



(format t "IS 3 IN THE LIST? : ~s ~%"
(if
(member 3 '
(2 4 6 8 10)) 't "Not in the list"))



(defparameter *num-list* '
(2 4 6 8 10))
(push 1 *num-list*)
(print *num-list*)
(format t "Second item in the list: ~a ~%"
(nth 2 *num-list*))

28 changes: 28 additions & 0 deletions program4.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(setq *print-case* :capitalize)

(format t "(expt 4 2) = ~d ~%"
(expt 4 2))
(format t "(sqrt 81) = ~d ~%"
(sqrt 81))
(format t "(exp 1) = ~d ~%"
(exp 1))
(format t "(log 1000 10) = ~d ~%"
(log 1000 10))
(format t "(eq 'dog 'dog) = ~d ~%"
(eq 'dog 'dog))
(format t "(floor 5.5) = ~d ~%"
(floor 5.5))
(format t "(ceiling 5.5) = ~d ~%"
(ceiling 5.5))
(format t "(max 5 10) = ~d ~%"
(max 5 10))
(format t "(min 5 10) = ~d ~%"
(min 5 10))
(format t "(oddp 15) = ~d ~%"
(oddp 15))
(format t "(evenp 15) = ~d ~%"
(evenp 15))
(format t "(numberp 12) = ~d ~%"
(numberp 2))
(format t "(null nil) = ~d ~%"
(null nil))
17 changes: 17 additions & 0 deletions program5.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(setq *print-case* :capitalize)

(defparameter *name* 'ICT)
(format t "(eq *name* 'ICT) = ~d ~%"
(eq *name* 'ICT))
(format t "(equal 'CAR 'ICT) = ~d ~%"
(equal 'CAR 'ICT))
(format t "(equal 10 10) = ~d ~%"
(equal 10 10))
(format t "(equal 5.5 5.3) = ~d ~%"
(equal 5.5 5.3))
(format t "(equal \"String 1\" \"String 123\" ) = ~d ~%"
(equal "String 1" "String 123"))
(format t "(equal (list 1 2 3) (list 1 2 3)) = ~d ~%"
(equal
(list 1 2 3)
(list 1 2 3)))
11 changes: 11 additions & 0 deletions program6.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(setq *print-case* :capitalize)

(defparameter *name* 'ICT)
(format t "(equalp 1.0 1) = ~d ~%"
(equalp 1.0 1))
(format t "(equal 1.0 1) = ~d ~%"
(equal 1.0 1))
(format t "(equalp \"ICT\" \"ict\") = ~d ~%"
(equalp "ICT" "ict"))
(format t "(equal \"ICT\" \"ict\") = ~d ~%"
(equal "ICT" "ict"))
30 changes: 30 additions & 0 deletions program7.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(setq *print-case* :capitalize)

;; (defparameter *name* 'ICT)
(print "Enter your age: ")
(defvar *age* (read))

;; (if(= *age* 18)
;; (format t "You can vote ~%")
;; (format t "You cannot vote ~%")
;; )



;; (if(not(= *age* 18))
;; (format t "You are 18 ~%")
;; (format t "You are not 18 ~%")
;; )



;; (if(and(>= *age* 18) (<= *age* 67))
;; (format t "Time for Work~%")
;; (format t "Work if you want ~%"))




(if(or(<= *age* 14) (>= *age* 67))
(format t "Yoy shouldn't Work~%")
(format t "Time for work ~%"))
25 changes: 25 additions & 0 deletions program8.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(setq *print-case* :capitalize)

(defparameter *num1* 2)
(defparameter *num2* 4)

(format t "Num1 : ~d~%" *num1*)
(format t "Num2 : ~d~%" *num2*)

(print "Enter a number to multiply: ")
(defparameter *num*
(read))

(if
(= *num* 2)
(progn
(setf *num1*
(* *num1* *num*))
(setf *num2*
(* *num2* *num*))
)
(format t "Not equal to 2~%")
)

(format t "Num1 : ~d~%" *num1*)
(format t "Num2 : ~d~%" *num2*)
33 changes: 33 additions & 0 deletions program9.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(setq *print-case* :capitalize)

(print "Enter a number (0-9): ")
(defparameter *num*
(read))

(defun get-num
(num)
(case num
(1
(print "One "))
(2
(print "Two "))
(3
(print "Three"))
(4
(print "Four "))
(5
(print "Five "))
(6
(print "Six "))
(7
(print "Seven "))
(8
(print "Eight "))
(9
(print "Nine "))
(0
(print "Zero "))
(otherwise
(print "Wrong Input"))
))
(get-num *num*)

0 comments on commit c642cbe

Please sign in to comment.