$isonly

By QuickStep on Jan 03, 2005

Function returns $true if v1 only contains characters found in v2

/*
Usage $isonly(v1,v2)

Case sensitive version:
$isonly(v1,v2).cs

For example:
$isonly(hello,abcdefghijklmnop) returns $true
$isonly(hello,abcdefg) returns $false
$isonly(Today is 2005,abcdefghijklmnopqrstuvwxyz 1234567890) returns $true
$isonly(Today is 2005,abcdefghijklmnopqrstuvwxyz 1234567890).cs returns $false
*/

alias isonly {
  var %a = 1
  while %a <= $len($$1) {
    if $mid($$1,%a,1) $+(!isin,$prop) $$2 return $false
    inc %a
  }
  return $true
}

Comments

Sign in to comment.
xDaeMoN   -  Jan 03, 2005

I see you already corrected your example. :) Nice code.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.