'Using one list with boolean to filter another list

I have 2 lists:

>logical.list  
$mask1  
[1] TRUE FALSE TRUE  
$mask2  
[1] FALSE TRUE FALSE  
>work.list  
$vector1  
[1] "a" "b" "c"  
$vector2  
[1] "d" "e" "f"  

I want to use the first one (logical.list) as a mask to extract the next output from work.list:

>output.list  
$vector1  
[1] "a" "c"  
$vector2  
[1] "e"  

Is there an elegant decision avoiding loops, lapply, etc.?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source