procgen  Check-in [294d779091]

Overview
Comment:tidy up headers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 294d779091b20c3249b5c507e1ba139551d1b29b2a186e76e85a1a5731f88475
User & Date: lexi on 2019-04-17 23:45:48
Other Links: manifest | tags
Context
2019-05-02
07:54
ipdates check-in: 588ff265a6 user: lexi tags: trunk
2019-04-17
23:45
tidy up headers check-in: 294d779091 user: lexi tags: trunk
22:45
remove outdated readme check-in: 6e90584b3f user: lexi tags: trunk
Changes

Modified lib/bot.scm from [851e9817dd] to [d5281d581a].

            1  +; [ʞ] bot.scm
            2  +;  ~ lexi hale <lexi@hale.su>
            3  +;  © affero general public license
            4  +;  > (load "lib/lisp-macro.scm")
            5  +;    (load "lib/bot.scm")
            6  +
     1      7   ; prep the random number generator
     2      8   (import (chicken random))
     3      9   (set-pseudo-random-seed! (random-bytes))
     4     10   
     5     11   ; generates a (case) structure that randomly returns
     6     12   ; one of its branches at equal probability
     7     13   (define-for-syntax (@one-of case-fn strs)

Added lib/fail.scm version [112daec7b2].

            1  +; [ʞ] fail.scm
            2  +; generates pretty error messages
            3  +
            4  +(define (fail . msg)
            5  +	(display (string-append "\x1b[1;31m - err.\x1b[0m " 
            6  +							(apply string-append msg)))
            7  +	(exit 1))
            8  +(define (fail:sym s)
            9  +  (fail "bad form \x1b[3;36m'" (symbol->string s) "\x1b[0m"))

Modified lib/interlace.scm from [fd266dcc3b] to [a82d9652e8].

     1         -; ʞ / interlace.scm
     2         -;   a scheme library by lexi hale
     3         -;
     4         -; (interlace) solves an age-old problem. what kind of data structure
     5         -; do you use when you need both an aggregate (a list, a vector) of
     6         -; items but also to be able to individually refer to those items by
     7         -; name? this problem is effectively unsolvable in C and C++ without
     8         -; inordinate runtime overhead, and there's no native syntax for it
     9         -; in Scheme. however, by rewriting the AST, we can implement a clean,
    10         -; performant, low-cost solution ourselves, thanks to the fact that
    11         -; (let*) bindings are expressions.
            1  +; [ʞ] interlace.scm
            2  +;  ~ lexi hale <lexi@hale.su>
            3  +;  © affero general public license
            4  +;  > (load "lib/lisp-macro.scm")
            5  +;    (load "lib/interlace.scm")
            6  +
            7  +; (interlace) solves  an old  problem. what kind  of data
            8  +; structure do  you use when  you need both  an aggregate
            9  +; (a  list,  a vector)  of  items  but  also to  be  able
           10  +; to  individually refer  to  those items  by name?  this
           11  +; problem is effectively unsolvable  in C and C++ without
           12  +; inordinate  runtime  overhead,  and there's  no  native
           13  +; syntax for it in Scheme. however, by rewriting the AST,
           14  +; we can implement a clean, performant, low-cost solution
           15  +; ourselves, thanks to the  fact that (let*) bindings are
           16  +; expressions.
    12     17   ;
    13         -; interlace takes a constructor function, e.g. (vector) or (list),
    14         -; a list of items, and returns an expression calling that constructor
    15         -; on a list of all items defined in it. if an item is proceded by
    16         -; an atom that ends in a period (e.g. “name.”), it is defined within
    17         -; a (let*) expression, and its name is then included among the
           18  +; interlace takes  a constructor function,  e.g. (vector)
           19  +; or (list), a  list of items, and  returns an expression
           20  +; calling that constructor on a list of all items defined
           21  +; in it. if an item is proceded by an atom that ends in a
           22  +; period (e.g.  “name.”), it  is defined within  a (let*)
           23  +; expression,  and its  name is  then included  among the
    18     24   ; arguments passed to the constructor function.
    19     25   ;
    20         -; the upshot of this is that items can reference other items by name
    21         -; *as they are being defined*. for instance:
           26  +; the upshot  of this is  that items can  reference other
           27  +; items  by  name  *as   they  are  being  defined*.  for
           28  +; instance:
    22     29   ;
    23         -;	(define verbs (interlace vector
    24         -;	                         talk. (verb "talk" "talking" "talked")
    25         -;		                         (phrasal-verb talk "to")
    26         -;		                         (phrasal-verb talk "about")
    27         -;		                     (verb "say" "saying" "said)))
           30  +; ex:	(define verbs (interlace vector
           31  +;			talk. (verb "talk" "talking" "talked")
           32  +;				(phrasal-verb talk "to")
           33  +;				(phrasal-verb talk "about")
           34  +;			(verb "say" "saying" "said)))
    28     35   ;
    29         -; here, the function to generate a phrasal verb exhibits backreference
    30         -; to an existing verb contained alongside it in the vector. note that 
    31         -; the name bindings are ephemeral; they do not survive the immediate
    32         -; context of the constructor.
           36  +; here, the function to  generate a phrasal verb exhibits
           37  +; backreference to  an existing verb  contained alongside
           38  +; it  in the  vector.  note that  the  name bindings  are
           39  +; ephemeral; they do not survive the immediate context of
           40  +; the constructor.
    33     41   
    34     42   (define-macro (interlace . body)
    35     43     ; given a list with both named and nameless members, identify
    36     44     ; which is which and instate the vector.
    37     45     (define (name? term)
    38     46   	; given a symbol, determine wheter it is a name, and if so return
    39     47   	; that name as a string and without the name-marking suffix ‹.›

Modified lib/lisp-macro.scm from [abec99f409] to [ad02b3f2ba].

     1      1   ; [ʞ] lisp-macro
     2         -; enable use of the define-macro syntax
     3         -; - example -
     4         -; 		(define-macro (if-or-f . body)
            2  +;  ~ lexi hale <lexi@hale.su>
            3  +;  © affero general public license
            4  +;  > (load "lib/lisp-macro.scm")
            5  +
            6  +; enable use of the define-macro syntax in chicken scheme
            7  +; ex:	(define-macro (if-or-f . body)
     5      8   ;			`(if ,(car body) ,(cadr body) #f))
     6      9   
     7     10   (define-syntax define-macro
     8     11   	(er-macro-transformer (lambda (exp r c)
     9     12   		`(define-syntax ,(caadr exp)
    10     13   			(er-macro-transformer
    11     14   				(lambda (,(cdadr exp) id-rename id-compare)
    12     15   					(let ((,(cdadr exp) (cdr ,(cdadr exp))))
    13     16   			 			,@(cddr exp))))))))

Modified lib/struct.scm from [833aa00a5f] to [06f94eb978].

     1         -; ʞ / struct.scm
            1  +; [ʞ] struct.scm
            2  +;  ~ lexi hale <lexi@hale.su>
            3  +;  © affero general public license
            4  +;  > (load "lib/struct.scm")
     2      5   ;
     3      6   ; generates immutable, relatively efficient structs. declare
     4      7   ; a struct type x with
     5      8   ;	(define x (struct 'field1 'field2) 
     6      9   ; create a record y of that type with
     7     10   ;	(define y (x 123 456))
     8     11   ; access field1 of record y with
     9     12   ;	(y 'field1)
    10     13   ; update field2 of record y with
    11     14   ;	(y 'field2 123) → new record (field1 = 123; field2 = 123)
    12     15   ;
    13         -; this unit also includes a few utility function that chicken
    14         -; scheme conveniently "forgot." i apologize for the implementation
    15         -; of (list-head). i was very tired.
           16  +; this  unit also  includes a  few utility  function that
           17  +; chicken scheme  conveniently "forgot." i  apologize for
           18  +; the implementation of (list-head). i was very tired.
    16     19   
    17     20   ; return a sub-list of lst up to ct (inverse of list-tail)
    18     21   (define (list-head lst ct)
    19     22     (let* ([reverse-lst (reverse lst)]
    20     23   		 [idx (- (length lst) (+ 1 ct))])
    21     24   	(reverse (list-tail reverse-lst idx))))
    22     25   	; i'm not proud of this

Modified lib/verb.scm from [98598e4655] to [fa196ac94e].

     1         -; ʞ / verb.scm
     2         -;	(depends lisp-macro.scm struct.scm)
     3         -;	a library by lexi hale
     4         -;
     5         -; macros, functions, and rules for conjugating verbs and 
     6         -; generating verb phrases. this library rules was written 
     7         -; specifically for english verbs and cannot be used as a
     8         -; "drop-in" library for other languages; however, the
     9         -; structured and functions used are sufficiently generic
    10         -; that it should be portable to other languages with
            1  +; [ʞ] verb.scm
            2  +;  ~ lexi hale <lexi@hale.su>
            3  +;  © affero general public license
            4  +;  > (load "lib/lisp-macro.scm")
            5  +;    (load "lib/struct.scm")
            6  +;    (load "lib/verb.scm")
            7  +
            8  +; macros, functions, and rules  for conjugating verbs and
            9  +; generating verb phrases. this library rules was written
           10  +; specifically for english verbs and  cannot be used as a
           11  +; "drop-in"  library for  other  languages; however,  the
           12  +; structured and functions  used are sufficiently generic
           13  +; that  it should  be  portable to  other languages  with
    11     14   ; minimal effort.
    12     15   
    13     16   ;;;; section i. generic functions & structures
    14     17   
    15     18   ; struct verb
    16     19   ;  fields contain conjugation functions for the specified
    17     20   ;  tense. ((v 'inf) object) will generate a verb phrase string
................................................................................
    21     24   ;   'ger: gerund (-ing form)
    22     25   ;   'pst: past (-ed form)
    23     26   ;   'ppl: past participle (often -ed or -en)
    24     27   ; * l10n note: the fields mentioned in the last line of the
    25     28   ;   (verb-form) macro must always match the fields listed in
    26     29   (define verb (struct 'inf 'prs 'ger 'adj 'pst 'ppl))
    27     30   
    28         -; takes a list of individual strings and joins them with
           31  +; takes a list of individual  strings and joins them with
    29     32   ; spaces. occurrences of "a" are automatically replace by
    30     33   ; "an" if the word following them appears to start with a
    31         -; vowel. this can be forcibly induced by preceeding that
           34  +; vowel. this can be  forcibly induced by preceeding that
    32     35   ; word with the symbol 'vowel in the list
    33     36   ; TODO: make it handle initialisms. yes, everything about
    34     37   ; this is horrible. yes, this *is* the wrong way to do it.
    35     38   ; yes, i *am* ashamed. why do you ask
    36     39   (define (word-append . body)
    37     40     (define (vowel? c) (member c '("a" "e" "i" "o" "u")))
    38     41     (define (vowel-onset? w)
................................................................................
    83     86   
    84     87   ; create a compound form a verb that already exists
    85     88   ; - prefix: prefix to append (e.g. up, out, over, un)
    86     89   ; - vb: final, "stem" verb
    87     90   (define (compound prefix vb) (lambda (form) (lambda (*o*)
    88     91   	  (word-append (string-append prefix ((vb form) *o*))))))
    89     92   
    90         -; create a verb where another string interposes between the
    91         -; root verb and the object. this can be used to implement
    92         -; object incorporation or prepositional verbs such as "get
    93         -; off on" (not to be confused with phrasal verbs)
    94         -; a phrasal verb.
           93  +; create a  verb where another string  interposes between
           94  +; the  root verb  and the  object.  this can  be used  to
           95  +; implement object  incorporation or  prepositional verbs
           96  +; such as "get  off on" (not to be  confused with phrasal
           97  +; verbs) a phrasal verb.
    95     98   ; - vb: the root (leftmost) verb
    96         -; - pps: the preposition complex immediately following the
    97         -;   verb.
           99  +; - pps: the preposition complex immediately following
          100  +;   the verb.
    98    101   (define (postpositive vb post) (lambda (form) (lambda (*o*)
    99    102   	(if (or (equal? form 'ppl) (equal? form 'adj))
   100    103   		(word-append
   101    104   		  (string-append ((vb form) '()) "-" post)
   102    105   		  *o*)
   103    106   		(word-append ((vb form) '()) post *o*)))))
   104    107