Add newLisp, our second interpreted lisp implementation that supports f-exprs today, (not in NixOS, but pretty easy to build, so inlined deriviation right in flake.nix). Implemented simple fib/fib-let test.

This commit is contained in:
Nathan Braswell
2022-07-03 00:50:00 -04:00
parent ace81e362e
commit b1817dfdc3
6 changed files with 262 additions and 0 deletions

View File

@@ -19,3 +19,4 @@ add_subdirectory(swift)
add_subdirectory(python)
add_subdirectory(scheme)
add_subdirectory(picolisp)
add_subdirectory(newlisp)

View File

@@ -0,0 +1,22 @@
set(copy_wrapper "../../copy_wrapper.sh")
set(sources newlisp-fib.nl newlisp-fib-let.nl)
foreach (source IN LISTS sources)
get_filename_component(name "${source}" NAME_WE)
set(out_dir "${CMAKE_CURRENT_BINARY_DIR}/out/bench")
set(out_path "${out_dir}/${name}")
add_custom_command(
OUTPUT ${out_path}
COMMAND ${copy_wrapper} "${CMAKE_CURRENT_SOURCE_DIR}/${source}" ${out_dir} ${name}
DEPENDS ${source}
VERBATIM)
add_custom_target(update-${name} ALL DEPENDS "${out_path}")
add_executable(${name}-exe IMPORTED)
set_target_properties(${name}-exe PROPERTIES IMPORTED_LOCATION "${out_path}")
endforeach ()

View File

@@ -0,0 +1,17 @@
#!/usr/bin/env newlisp
;;
;; fibonacci series
;; mostly from http://www.newlisp.org/syntax.cgi?benchmarks/fibo.newlisp.txt
;; modified slightly to match others
;;
(define (fib n)
(cond ((= 0 n) 1)
((= 1 n) 1)
(true (let (a (fib (- n 1))
b (fib (- n 2))
) (+ a b)))))
(println (fib (integer (main-args 2))))
(exit)

View File

@@ -0,0 +1,15 @@
#!/usr/bin/env newlisp
;;
;; fibonacci series
;; mostly from http://www.newlisp.org/syntax.cgi?benchmarks/fibo.newlisp.txt
;; modified slightly to match others
;;
(define (fib n)
(cond ((= 0 n) 1)
((= 1 n) 1)
(true (+ (fib (- n 1)) (fib (- n 2))))))
(println (fib (integer (main-args 2))))
(exit)