title: Implementing the calculator program using lisp
body: <p>I'm  implementing the calculator program using concurrent lisp programming language..Everything is working fine..but I want to print which thread is executing currently  and the particular function..however I'm able to get the list of thread using list-all-threads function...please suggest me how to do it..</p>
  
  <p>following is my code with output::</p>
  
  <pre><code>(defvar a)     // defines a var but does not initialises it
  (defvar b)
  (defvar c)
  (defvar d)
  
  
  (write-line " Enter two numbers in binary format with prefix #b : ")  // gives newline afterwords
  
  
      (setf a (read))  
  
    /* SETF is a macro which uses SETQ internally, but has more possibilities. In a way it's a more general assignment operator.*/
  
       (setf b(read))
  
      (sb-thread:make-thread(lambda()(progn (sleep 4)(setf c(+ a   b))
                  (print "ADDITION in binary: ")
                  (format t " ~b" c )
                  (print "ADDITION in decimal: ")
                  (print c)
                  )
                  )
                  )
  
      (sb-thread:make-thread(lambda()(progn(sleep 2)(setf c(- a b))
                  (print "SUBTRACTION in binary: ")
                  (format t " ~b" c )  
                  (print "SUBTRACTION in decimal: ")
                  (print c))))
  
      (sb-thread:make-thread(lambda()(progn(sleep 5)(setf c(* a b))
                  (print "MULTIPLICATION in binary: ")
                  (format t " ~b" c )
                  (print "MULTIPLICATION IN DECIMAL: ")
                  (print c))))
  
      (sb-thread:make-thread(lambda()(progn(sleep 3)(setf c(* a a))
                  (print "SQUARE in binary: ")
                  (format t " ~b" c )
                  (print "SQUARE OF 1st NUMBER  : ")
                  (print c))))
  
      (sb-thread:make-thread(lambda()(progn(sleep 1)(setf c(* b b b))
                  (print "CUBE OF 2ND NUMBER : ")
                  (print c))))    
  
  
      (sb-thread:make-thread(lambda()(progn(sleep 2)(setf c(sin a))
                  (print "SINE OF 1ST NUMBER : ")
                  (print c))))
  
      (sb-thread:make-thread(lambda()(progn(sleep 3)
                  (setf c(tan a))
                  (print "TAN OF 1ST NUMBER : ")
                  (print c))))
  
      (sb-thread:make-thread(lambda()(progn(sleep 6)
                  (setf c(cos a))
                  (print "COSINE OF 1ST NUMBER : ")
                  (print c))))
  
      (sb-thread:make-thread(lambda()(progn(sleep 2)
                  (setf c(min a b))
                  (print "MINIMUM NUMBER : ")
                  (print c))))
  
      (sb-thread:make-thread(lambda()(progn(sleep 1)
                  (setf c(max a b))
                  (print "MAXIMUM NUMBER : ")
                  (print c))))
  
  (print (sb-thread:list-all-threads))
  (sleep 30 )       
  
  (exit)
  
  ----------------------------------------------------------------------------------------
  
  OUTPUT:
  
  [CGL@localhost ~]$ sbcl
  This is SBCL 1.2.8.14-8b3c9d0, an implementation of ANSI Common Lisp.
  More information about SBCL is available at &lt;http://www.sbcl.org/&gt;.
  
  SBCL is free software, provided as is, with absolutely no warranty.
  It is mostly in the public domain; some portions are provided under
  BSD-style licenses.  See the CREDITS and COPYING files in the
  distribution for more information.
  * (load "test.lisp")
   Enter two numbers in binary format with prefix #b : 
  #b1100
  #b1011
  
  (#&lt;SB-THREAD:THREAD RUNNING {100322E8E3}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {10031E4263}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {1003190D33}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {10031750D3}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {1003157A73}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {10031393E3}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {1003119E43}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {10030D91C3}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {1003097C33}&gt;
   #&lt;SB-THREAD:THREAD RUNNING {1003057903}&gt;
   #&lt;SB-THREAD:THREAD "main thread" RUNNING {1002FCE543}&gt;) 
  "CUBE OF 2ND NUMBER : " 
  1331 
  "MAXIMUM NUMBER : " 
  12 
  "SUBTRACTION in binary: "  1
  "SUBTRACTION in decimal: " 
  1 
  "SINE OF 1ST NUMBER : " 
  -0.53657293 
  "MINIMUM NUMBER : " 
  11 
  "SQUARE in binary: "  10010000
  "SQUARE OF 1st NUMBER  : " 
  144 
  "TAN OF 1ST NUMBER : " 
  -0.6358599 
  "ADDITION in binary: "  10111
  "ADDITION in decimal: " 
  23 
  "MULTIPLICATION in binary: "  10000100
  "MULTIPLICATION IN DECIMAL: " 
  132 
  "COSINE OF 1ST NUMBER : " 
  0.84385395 [CGL@localhost ~]$
  </code></pre>