From d05841efc07ad0300dbfe2d3f3d67131434a8e3c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku <kaz@kylheku.com> Date: Mon, 12 Dec 2016 06:35:12 -0800 Subject: Adding mismatch function. * eval.c (eval_init): Register mismatch intrinsic. * lib.c (mismatch): New function. * lib.c (mismatch): Declared. * txr.1: Documented mismatch. --- txr.1 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 549a7da3..78f72bf4 100644 --- a/txr.1 +++ b/txr.1 @@ -24729,6 +24729,47 @@ from is passed through this one-argument function, and the resulting value is used in its place. +.coNP Function @ mismatch +.synb +.mets (mismatch < left-seq < right-seq >> [ testfun <> [ keyfun ]]) +.syne +.desc +The +.code mismatch +function compares corresponding elements from the sequences +.meta left-seq +and +.metn right-seq , +returning the position at which the first mismatch occurs. + +If the sequences are of the same length, and their corresponding +elements are the same, then +.code nil +is returned. + +If one sequence is shorter than the other, and matches a prefix +of the other, then the mismatching position returned is one position +after the last element of the shorter sequence, the same value +as its length. An empty sequence is a prefix of every sequence. + +The +.meta keyfun +argument defaults to the +.code identity +function. Each element +from +.meta sequence +is passed to +.meta keyfun +and the resulting value is used in its place. + +After being converted through +.metn keyfun , +items are then compared using +.metn testfun , +which must accept two arguments, and defaults to +.codn equal . + .coNP Function @ where .synb .mets (where < function << object ) -- cgit v1.2.3