Arc Forumnew | comments | leaders | submitlogin
1 point by wgac 5654 days ago | link | parent

I found some errors in the recent post. Here is the (I hope so) final version or rez and imz. Enjoy :)

    ;;Realis of complex number z
    (def rez (z)
         (with (lz (tocons z) i 0 j 0)
         (until (or (is i (len lz))
                    (and (isnt (lz j) #\e)
                         (or (is (lz i) #\+)
                             (is (lz i) #\-)))) 
            (if (is i 0) (++ i) (do (++ i) (++ j))))
            (toint (firstn i lz))))

    ;;Imaginaris of complex number z
    (def imz (z)
         (with (lz (tocons z) i 0 j 0)
         (until (or (is i (len lz))
         	    	(and (isnt (lz j) #\e)
	    	     (or (is (lz i) #\+)
	    	     	 (is (lz i) #\-)))) 
    	(if (is i 0) (++ i) (do (++ i) (++ j))))
    	(toint (if (pos #\i lz) (rem #\i (nthcdr i lz)) 0))))