It'd be nice to have an OR operator for $bfind. Currently to search for multiple sets of characters you have to either manually loop over the bvar checking if character(s) match one of the possibilities, or compare multiple $bfind entries. For example
Code:
;; $bsearch(bvar, pos, queryA, queryB, queryC, ...)
alias bsearch {
  var %match, %test, %x = 3
  while (%x <= $0) {
    %test = $bfind($1, $2, $($ $+ %x, 2)) [ $+ [ $iif($prop, . $+ $prop) ] ]
    if (%test && (!%match || %test < %match)) {
      %match = %test
    }
    inc %x
  }
  return %match
}


This can be slow depending on the size of the bvar, how many differing items are to be searched for, and how many times those differing items are to be searched

I suggest that $bfind allow extra arguments to represent an OR search:
Code:
$bfind(&bvar, 1, a, b, c, d)
Starting at the position 1, searches for the first byte that matches "a" OR "b" OR "c" or "d" in &bvar and returns its position. This would keep backwards compatibility while extending $bfind to have an OR operator

Last edited by FroggieDaFrog; 14/05/15 08:44 PM.

I am SReject
My Stuff