Clean up ++so-first-grams and ++so-in-range using =*.

This commit is contained in:
Fang 2018-03-07 01:20:55 +01:00
parent 1b92e26497
commit 542e3a33d6

View File

@ -1228,7 +1228,8 @@
|= ran/range
^- (list telegram)
=+ [num=0 gaz=grams zeg=*(list telegram)]
:: fill in empty ranges to select all grams.
:: fill in empty ranges to select all grams,
:: and calculate absolutes for relative places.
=. ran
?~ ran `[[%ud 0] `[%ud count]]
=* hed hed.u.ran
@ -1241,24 +1242,26 @@
ran
:: never fails, but compiler needs it.
?> &(?=(^ ran) ?=(^ tal.u.ran))
=* hed hed.u.ran
=* tal u.tal.u.ran
%- flop
|- ^- (list telegram)
?~ gaz zeg
?: ?- -.u.tal.u.ran :: after the end
$ud (lth +.u.tal.u.ran num)
$da (lth +.u.tal.u.ran wen.i.gaz)
?: ?- -.tal :: after the end
$sd !! :: caught above
$ud (lth +.tal num)
$da (lth +.tal wen.i.gaz)
==
:: if past the river, we're done searching.
:: if past the range, we're done searching.
zeg
?: ?- -.hed.u.ran :: before the start
$ud (lth num +.hed.u.ran)
$da (lth wen.i.gaz +.hed.u.ran)
?: ?- -.hed :: before the start
$sd !! :: caught above
$ud (lth num +.hed)
$da (lth wen.i.gaz +.hed)
==
:: if before the river, continue onward.
:: if before the range, continue onward.
$(num +(num), gaz t.gaz)
:: if in the river, add this gram and continue.
:: if in the range, add this gram and continue.
$(num +(num), gaz t.gaz, zeg [i.gaz zeg])
::
++ so-in-range
@ -1274,18 +1277,20 @@
^- {in/? done/?}
?~ ran [& |]
=/ min
?- -.hed.u.ran
=* hed hed.u.ran
?- -.hed
$sd & :: relative is always in.
$ud (gth count +.hed.u.ran)
$da (gth now.bol +.hed.u.ran)
$ud (gth count +.hed)
$da (gth now.bol +.hed)
==
?~ tal.u.ran
[min |]
=- [&(min -) !-]
?- -.u.tal.u.ran
=* tal u.tal.u.ran
?- -.tal
$sd | :: relative is always done.
$ud (gte +(+.u.tal.u.ran) count)
$da (gte +.u.tal.u.ran now.bol)
$ud (gte +(+.tal) count)
$da (gte +.tal now.bol)
==
::
:> #