* Tree Generation - Lisp

Lisp programme to generate the following structure:

*
**
***
****
*****
******
Program: 
Download Runnable Code
(defun gen(n)
    (dotimes(x (+ n 1) t)
        (dotimes(y x t)  (format t "*")
        )
        (format t "~&")
    )
)
Output:
Break 2 [4]> (load 'ge.lsp)
;; Loading file ge.lsp ...
;; Loaded file ge.lsp
T
Break 2 [4]> (gen 6)
*
**
***
****
*****
******
 
Download 

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...