[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

curly-infix examples

This page is part of the web mail archives of SRFI 105 from before July 7th, 2015. The new archives for SRFI 105 contain all messages, not just those from before July 7th, 2015.



FYI, here is every curly-infix-expression (c-expression) in "sweeten" (a list-processing program I wrote) and "letterfall" (a GUI real-time game written by Alan Manuel Gloria).  I thought might be useful to see "actual examples" to see if it all makes sense.  I think it *does* make sense.

Duplicates were not removed; if the same expression appears multiple times, that's useful information.  I did include one neoteric-expression not{...}.  One of these expressions crossed multiple lines, but for analysis purposes I merged it into one line (so that counting, etc., was easier).

Basic stats: These two programs, combined, have 78 examples of c-expressions (not counting c-expressions embedded in c-expressions).  Of these examples, 55/78 (71%) do NOT embed a curly-brace in a curly-brace. Thus, more than 2/3s of the curly-infix expressions in these programs are relatively simple things like {count-so-far + 1} and {length(x) >= 3}.  Notice that allowing infix operators like "char=?", "eq?", and "remainder" really can be useful.

--- David A. Wheeler

=== sweeten ===
{length(indent-increment) * 3}
{length(indent) - length(marked-indent-increment)}
{{length(indent) > min-indent-marking} and last-indent-unmarked(indent)}
{length(x) < boring-length}
{count-so-far + 1}
{count-so-far + 1}
{length(x) >= 3}
{length(x) <= 6}
{pair?(x) and null?(cdr(x))}
{pos + length(item)}
{{pos + length(item-sameline)} < maxwidth}
{pos + length(item-sameline)}
{{posdent(indent-already indent) + newlen} < maxwidth}
{memq(car(m) cuddle-first-parameter) and {length(m) >= 3}}
{ {length-asline < max-unit-character-length} and fits-width?(indent-already indent length-asline) and {general-length(m) < max-unit-list-length} }
{char?(car(x)) and null?(cdr(x)) and {car(x) eq? #\newline}}
{not{c eq? next} and memq(next end-of-line-chars)}
{c char=? #\;}
{{c char=? #\space} or {c char=? tab}}


=== letterfall ===
{{ 64 < n } and { n <= { 64 + 26 }}}
{ n - 64 - 1 }
{{ 96 < n } and { n <= { 96 + 26 }}}
{ n - 96 - 1 }
{{ 48 <= n } and { n <= { 48 + 9 }}}
{ n - 48 }
{ c char=? #\- }
{ c char=? #\' }
{ kv <= 126 }
{ kv = gdk:Escape }
{ char-toupper(k) char=? c }
{ col + 1 }
{ 20 - inexact->exact(floor{ len / 2 })}
{ 7 + n }
{ 64 + n + 1 }
{ char-toupper(k) char=? char }
{ score + 1 }
{{ nscore remainder 10 } = 0 }
{ level + 1 }
{ k char=? esc-key }
{ line + 1 }
{ line = 22 }
{ line + 1 }
{ k char=? esc-key }
{{ 0.75 expt level } * 400 }
{{ 96 < n } and { n <= { 96 + 26 }}}
{ n - 32 }
{ 40 * 25 }
{ 40 * 25 }
{ n = { 40 * 25 }}
{ n + 1 }
{ x + { y * 40 }}
{ cursor + 1 }
{ cursor >= { 40 * 25 }}
{ i = end }
{ i + 1 }
{ screen-width / 320 }
{ screen-height / 200 }
{ 40 * 25 }
{ x + 1 }
{ y + 1 }
{ rescaled<x+1> - rescaled<x> }
{ rescaled<y+1> - rescaled<y> }
{{ screen-width / 2 } + {{ x - 160 } * scaling-factor }}
{{ screen-height / 2 } + {{ y - 100 } * scaling-factor }}
{ n = { 40 * 25 }}
{ n / 40 }
{ n - { l * 40 }}
not{ vector-ref(display-screen n) char=? vector-ref(latest-screen n) }
{ n + 1 }
{ c * 8 }
{ l * 8 }
{ i = 8 }
{ i + 1 }
{ x = 8 }
{{ line logand { 2 expt { 7 - x }}} = 0}
{ basex + x }
{ basey + y }
{ x + 1 }



=== {} embedded in {} ===
The following is the output of:   cat braces-* | grep '{[^}]*{'

{{ 64 < n } and { n <= { 64 + 26 }}}
{{ 96 < n } and { n <= { 96 + 26 }}}
{{ 48 <= n } and { n <= { 48 + 9 }}}
{ 20 - inexact->exact(floor{ len / 2 })}
{{ nscore remainder 10 } = 0 }
{{ 0.75 expt level } * 400 }
{{ 96 < n } and { n <= { 96 + 26 }}}
{ n = { 40 * 25 }}
{ x + { y * 40 }}
{ cursor >= { 40 * 25 }}
{{ screen-width / 2 } + {{ x - 160 } * scaling-factor }}
{{ screen-height / 2 } + {{ y - 100 } * scaling-factor }}
{ n = { 40 * 25 }}
{ n - { l * 40 }}
{{ line logand { 2 expt { 7 - x }}} = 0}
{{length(indent) > min-indent-marking} and last-indent-unmarked(indent)}
{{pos + length(item-sameline)} < maxwidth}
{{posdent(indent-already indent) + newlen} < maxwidth}
{memq(car(m) cuddle-first-parameter) and {length(m) >= 3}}
{ {length-asline < max-unit-character-length} and fits-width?(indent-already indent length-asline) and {general-length(m) < max-unit-list-length} }
{char?(car(x)) and null?(cdr(x)) and {car(x) eq? #\newline}}
{not{c eq? next} and memq(next end-of-line-chars)}
{{c char=? #\space} or {c char=? tab}}