query
On this page

commonSuffixLength

lib.strings.commonSuffixLength

Docs pulled from | This Revision | about 1 hour ago


Returns the length of the suffix common to both strings a and b.

Inputs

a
1. Function argument
b
2. Function argument

Type

commonSuffixLength :: string -> string -> int

Noogle detected

Implementation

The following is the current implementation of this function.

commonSuffixLength =
    a: b:
    let
      m = lib.min (stringLength a) (stringLength b);
      go =
        i:
        if i >= m then
          m
        else if substring (stringLength a - i - 1) 1 a == substring (stringLength b - i - 1) 1 b then
          go (i + 1)
        else
          i;
    in
    go 0;