haskell-te: 9cc1fc71e6dcd70e7e1e627d2c36b40aeac08f2a

     1: { lib, reverse }:
     2: with builtins;
     3: with lib;
     4: with rec {
     5:   # Technically allows things like '.....' as numbers, but meh
     6:   isDigit = x: any (n: n == x) (stringToCharacters "0123456789.");
     7: 
     8:   numeric = x: all isDigit (stringToCharacters x);
     9: 
    10:   stripNums = xs: if xs == []
    11:                      then []
    12:                      else if numeric (head xs)
    13:                              then stripNums (tail xs)
    14:                              else xs;
    15: 
    16:   stripEndNums = xs: reverse (stripNums (reverse xs));
    17: 
    18:   stripVersion = s: concatStringsSep "-" (stripEndNums (splitString "-" s));
    19: 
    20:   testExpect = "list-extras";
    21:   testInput  = "list-extras-0.4.1.4";
    22:   testOutput = stripVersion testInput;
    23: };
    24: 
    25: assert testOutput == testExpect ||
    26:        abort (toJSON { inherit testExpect testInput testOutput; });
    27: stripVersion

Generated by git2html.