Jump to content

Modulinos: Difference between revisions

Added newLISP
(Added Common Lisp)
(Added newLISP)
Line 1:
{{task|Basic language learning}}[[Category: UNIX Shell]]
It is useful to be able to runexecute a main() function only when a program is run directly. This is a central feature in programming scripts; the feature is called /scripted main/.
 
Examples from [https://github.com/mcandre/scriptedmain GitHub].
Line 157:
}
}</lang>
 
=={{header|newLISP}}==
newLISP lacks scripted main, but the feature is easily added.
 
<lang lisp>#!/usr/bin/env newlisp
 
(context 'SCRIPTED-MAIN)
 
(define (main)
(println "Directory: " (real-path))
 
(println "Program: " (main-args 1))
 
(println "Number of Args: " (length (main-args)))
 
(map (lambda (x) (println "Arg: " x)) (main-args))
 
(exit))
 
(if (find "scriptedmain" (main-args 1)) (main))
 
(context MAIN)</lang>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.