/usr/share/doc/wadc/include/lisp.h is in wadc 2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /*
* lisp.h - part of WadC
* Copyright © 2001-2008 Wouter van Oortmerssen
* Copyright © 2008-2016 Jonathan Dowland <jon@dow.land>
*
* Distributed under the terms of the GNU GPL Version 2
* See file LICENSE.txt
*/
-- basic constructor/accessor functions
cons(a, b) { sethdtl(onew, a, b) }
sethdtl(_o, a, b) { sethd(_o, a) settl(_o, b) _o } -- '_' essential here
sethd(o, h) { oset(o, "hd", h) }
settl(o, t) { oset(o, "tl", t) }
hd(o) { oget(o, "hd") }
tl(o) { oget(o, "tl") }
nil() { -1 } -- int value of other objects is >=0!
-- for convenience
list1(a) { cons(a, nil) }
list2(a, b) { cons(a, cons(b, nil)) }
list3(a, b, c) { cons(a, cons(b, cons(c, nil))) }
list4(a, b, c, d) { cons(a, cons(b, cons(c, cons(d, nil)))) }
list5(a, b, c, d, e) { cons(a, cons(b, cons(c, cons(d, cons(e, nil))))) }
-- useful functions
-- can be made a lot faster when made eager, i.e. _x and _y...
-- (currently normal order evaluation)
append(x, y) {
eq(x, nil)
? y
: cons(hd(x), append(tl(x), y))
}
map(x, f) {
eq(x, nil)
? nil
: cons(set("mapvar", hd(x)) f, map(tl(x), f))
}
mapvar() { get("mapvar") } -- our closures can't take arguments
|