Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added spec for :vk subscript adverbial
I assume we will need a .vk method later as well.  Will spec this later unless
someone beats me to it / tells me not to do it.
  • Loading branch information
lizmat committed May 22, 2013
1 parent f868fd3 commit 451c4bb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions S02-bits.pod
Expand Up @@ -2450,20 +2450,23 @@ appropriate adverb to the subscript.
@array[0,1,2] :kv; # returns 0, 'A', 1, 'B'
@array[0,1,2] :k; # returns 0, 1
@array[0,1,2] :v; # returns 'A', 'B'
@array[0,1,2] :vk; # returns 'A', 0, 'B', 1

%hash = (:a<A>, :b<B>);
%hash<a b c>; # returns 'A', 'B', (Any)
%hash<a b c> :p; # returns a => 'A', b => 'B'
%hash<a b c> :kv; # returns 'a', 'A', 'b', 'B'
%hash<a b c> :k; # returns 'a', 'b'
%hash<a b c> :v; # returns 'A', 'B'
%hash<a b c> :vk; # returns 'A', 'a', 'B', 'b'

These adverbial forms all weed out non-existing entries if the
adverb is true; if not, they leave them in, just as an ordinary slice would.
So:

@array[0,1,2] :!p; # returns 0 => 'A', 1 => 'B', 2 => (Any)
%hash<a b c> :!kv; # returns 'a', 'A', 'b', 'B', 'c', (Any)
%hash<a b c> :!vk; # returns 'A', 'a', 'B', 'b', (Any), 'c'

Likewise,

Expand Down Expand Up @@ -2534,16 +2537,20 @@ These combinations are considered legal and mean the following:
:delete :!p delete, return pairs of all keys attempted
:delete :kv delete, return key/values of actually deleted keys
:delete :!kv delete, return key/values of all keys attempted
:delete :v delete, return values of actually deleted keys
:delete :!v delete, return values of all keys attempted
:delete :k delete, return actually deleted keys
:delete :!k delete, return all keys attempted to delete
:delete :v delete, return values of actually deleted keys
:delete :!v delete, return values of all keys attempted
:delete :vk delete, return value/keys of actually deleted keys
:delete :!vk delete, return value/keys of all keys attempted
:delete :exists delete, return Bools indicating keys existed
:delete :!exists delete, return Bools indicating keys did not exist
:delete :exists :p delete, return pairs with key/True for key existed
:delete :exists :!p delete, return pairs with key/Bool whether key existed
:delete :exists :kv delete, return list with key,True for key existed
:delete :exists :!kv delete, return list with key,Bool whether key existed
:delete :exists :vk delete, return list with True,key for key existed
:delete :exists :!vk delete, return list with Bool,key whether key existed

An implementation is free to silently ignore any other combinations or
silently prefer one of the adverbs given above any other.
Expand Down

0 comments on commit 451c4bb

Please sign in to comment.