From a23765ce50e30e655255b3eb24db91d4582cb68a Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Sun, 3 Oct 2010 02:34:31 -0400 Subject: [PATCH 1/1] tweak advanced Signed-off-by: Jim Pryor --- miscellaneous_lambda_challenges_and_advanced_topics.mdwn | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/miscellaneous_lambda_challenges_and_advanced_topics.mdwn b/miscellaneous_lambda_challenges_and_advanced_topics.mdwn index ea07a841..0342fc64 100644 --- a/miscellaneous_lambda_challenges_and_advanced_topics.mdwn +++ b/miscellaneous_lambda_challenges_and_advanced_topics.mdwn @@ -324,7 +324,7 @@ can use. This "handler" encodes the search's having finished, and delivering a final answer to whatever else you wanted your program to do with the result of the search. If you like, at any stage in the search you might just give an argument - to this handler, instead of giving an argument to the handler that continues + to *this* handler, instead of giving an argument to the handler that continues the list traversal leftwards. Semantically, this would amount to *aborting* the list traversal! (As we've said before, whether the rest of the list traversal really gets evaluated will depend on what evaluation order is in place. But @@ -339,8 +339,8 @@ can use. f 3 - `f`'s job would be to check whether 3 matches the element we're searching for - (here also 3), and if it does, just evaluate to the result of passing `true` to + `f`'s job would be to check whether `3` matches the element we're searching for + (here also `3`), and if it does, just evaluate to the result of passing `true` to the abort handler. If it doesn't, then evaluate to the result of passing `false` to the continue-leftwards handler. @@ -355,27 +355,28 @@ can use. of the list multiplied to, because that would affect the answer you passed along to the continue-leftwards handler. - A **version 5** list would encode this kind of fold operation over the list, in + A **version 5** list encodes the kind of fold operation we're envisaging here, in the same way that v3 (and v4) lists encoded the simpler fold operation. Roughly, the list `[5;4;3;2;1]` would look like this: \f z continue_leftwards_handler abort_handler. - + (\result_of_fold_over_4321. f 5 result_of_fold_over_4321 continue_leftwards_handler abort_handler) abort_handler + ; or, expanding the fold over [4;3;2;1]: \f z continue_leftwards_handler abort_handler. (\continue_leftwards_handler abort_handler. - + (\result_of_fold_over_321. f 4 result_of_fold_over_321 continue_leftwards_handler abort_handler) abort_handler ) (\result_of_fold_over_4321. f 5 result_of_fold_over_4321 continue_leftwards_handler abort_handler) abort_handler - and so on + ; and so on Remarks: the `larger_computation_handler` should be supplied as both the `continue_leftwards_handler` and the `abort_handler` for the leftmost -- 2.11.0