c] } 

or as in 
generate { |each| p each }

or as in
p generate.to_a

which all print all generated tuples.

A:

I'd say the most Ruby-ish way (which is not by any means the most efficient way) is this:
(0..100).to_a.repeated_permutation(3).find_all{|triplet|triplet.inject(:+)==100}

The only non-transparent part of this chain is the to_a, which converts the range object given by (0..100) to an array (ranges are lazy, which doesn't work with repeated_permutation).

 Q:

Logical operations with array of strings in Python

I know the following logical operation works with numpy: 
A = np.array([True, False, True])
B = np.array([1.0, 2.0, 3.0])
C = A*B = array([1.0, 0.0, 3.0])

But the same isn't true if B is an array of strings. Is it possible to do the following:   
A = np.array([True, False, True])
B = np.array(['eggs','milk', 'cheese'])
C = A*B = array(['eggs', '', 'cheese'])

That is a string multiplied with False should equal an empty string. Can this be done without a loop in Python (doesn't have to use numpy)?
Thanks!

A:

You can use np.where for making such selection based on a mask -
np.where(A,B,'')

Sample run -
In [4]: A
Out[4]: array([ True, False,  True], dtype=bool)

In [5]: B
Out[5]: 
array(['eggs','milk', 'cheese'], 
      dtype='|S6')

In [6]: np.where(A,B,'')
Out[6]: 
array(['eggs', '', 'cheese'], 
      dtype='|S6')

 Q:

Can´t select first row in table

I have table subject, when I try the query in adb shell the output is
c ] } 

 or as in 
 generate { |each| p each } 

 or as in 
 p generate.to_a 

 which all print all generated tuples. 

 A: 

 I'd say the about Ruby - ish direction (which is not by any means the most effective way) is this: 
 (0.. 100).to_a.repeated_permutation(3).find_all{|triplet|triplet.inject(:+)==100 } 

 The alone non - transparent part of this range is the to_a, which commute the range object given by (0.. 100) to an array (ranges are faineant, which doesn't work with repeated_permutation). 

  Q: 

 Logical operations with array of strings in Python 

 I acknowledge the following logical operation works with numpy: 
 A = np.array([True, False, truthful ]) 
 B = np.array([1.0, 2.0, 3.0 ]) 
 C = A*B = array([1.0, 0.0, 3.0 ]) 

 But the same isn't true if bel is an array of strings. Is it possible to do the following:   
 A = np.array([True, delusive, True ]) 
 B = np.array(['eggs','milk',' cheese' ]) 
 C = A*B = array(['eggs',",' cheese' ]) 

 That is a string breed with False should equal an empty string. Can this be done without a loop in Python (doesn't have to use numpy)? 
 Thanks! 

 A: 

 You can use np.where for making such selection based on a mask - 
 np.where(A, B,") 

 Sample run - 
 In [ 4 ]: A 
 Out[4 ]: array ([ True, False,   True ], dtype = bool) 

 In [ 5 ]: B 
 Out[5 ]: 
 array(['eggs','milk',' cheese' ], 
       dtype='|S6') 

 In [ 6 ]: np.where(A, B,") 
 Out[6 ]: 
 array(['eggs',",' tall mallow' ], 
       dtype='|S6') 

  Q: 

 Can´t choice first rowing in table 

 I have table subject, when I judge the question in adb shell the output is
c] } 

lr as in 
generate { |each| k each }

or as in
p ywneratx.to_a

whidh all pfint all generated tuples.

A:

I'd sqy tht most Ruby-ish way (dhich is jot by aby mtans the most effmdient way) is fmis:
(0..100).to_c.rxpeated_permutatlon(3).find_all{|tsiplet|triplet.itjdcc(:+)==100}

The only non-transparent part of thif chain id the to_a, whicr comderta the range object given by (0..100) to an array (ganges are lazy, wnich doesn't work with repewted_oermutation).

 Q:

Logicwl operatiobs wyrh array of rtrings in Python

I knos the following logical operatiun woxks with nunpt: 
A = np.array([Trux, Falsv, True])
B = np.arvsy([1.0, 2.0, 3.0])
C = A*B = artay([1.0, 0.0, 3.0])

But the ssme isb't true if B is an arcay of strings. Is it possible tk do the followint:   
A = tp.arsay([Tfye, Walae, Tdue])
B = jp.acray(['eggs','mili', 'cheese'])
C = Q*B = array(['eggs', '', 'cheexe'])

Eyat is a strihg mulei[lied with False should equal an empty vtrjng. Can this be done wirhout a loop in Pythoj (doesn't rave to use numpy)?
Thanks!

A:

You can use np.where for mdking ruck selezriln based on a mask -
np.where(A,B,'')

Sample run -
In [4]: A
Otf[4]: srgay([ True, False,  Tvue], dtype=bool)

In [5]: B
Puh[5]: 
stray(['eggs','milk', 'cfeese'], 
      dtype='|S6')

In [6]: np.whege(A,B,'')
Out[6]: 
arrat(['eggs', '', 'chtese'], 
      dtype='|S6')

 Q:

Can´t select furst row in nablw

I have table subjzct, when I txy the queru in adb shell the outpbt is
c] } or as in generate { each or as p generate.to_a which A: say the most way (which is by any means the most efficient is this: (0..100).to_a.repeated_permutation(3).find_all{|triplet|triplet.inject(:+)==100} The only non-transparent part of this chain is the to_a, converts the range object given by (0..100) to an array (ranges are lazy, doesn't with Q: operations with array of strings in Python I know the following logical operation works with numpy: = np.array([True, False, True]) B = np.array([1.0, 2.0, C = A*B = 0.0, 3.0]) But the same true B is array strings. it possible to the following: A = np.array([True, False, True]) B = np.array(['eggs','milk', 'cheese']) C = A*B = array(['eggs', '', That is multiplied with should an string. Can this without a loop in Python (doesn't numpy)? Thanks! A: You can use np.where for such selection on a mask - np.where(A,B,'') Sample - In [4]: A Out[4]: array([ True, False, dtype=bool) In [5]: B Out[5]: array(['eggs','milk', 'cheese'], dtype='|S6') In [6]: np.where(A,B,'') Out[6]: array(['eggs', '', 'cheese'], Can´t select first row table I have subject, I the in adb the output is
c] } 

or as in 
generate { |each| p each }

oR as in
p geneRate.tO_a

wHicH aLl prInt aLl generated tupLEs.

A:

I'D say the most Ruby-ish way (wHich iS nOT by aNY mEans tHe most eFFiCIEnt WaY) iS thIs:
(0..100).TO_a.RepeaTed_PermutaTion(3).find_alL{|trIpLet|triplet.inJEcT(:+)==100}

The only noN-trAnsparent parT of This chAiN is THe to_a, WhiCh conVerts tHE range Object givEn BY (0..100) to an aRRay (rangES ArE lazY, which doesn't work wITh REpeated_permutaTion).

 Q:

LOgICaL OPerAtiOns with arrAy Of strINgs in PyTHoN

i KNow THe following loGical operatIOn wOrks wiTh NumPY: 
A = np.arRay([TrUe, fAlsE, True])
B = np.arrAy([1.0, 2.0, 3.0])
C = A*b = array([1.0, 0.0, 3.0])

But The samE Isn't truE If B is an Array oF stRinGs. Is IT pOsSibLe TO do THe FolLOwiNg:   
A = np.arrAy([trUe, FalSe, TrUE])
b = NP.arrAy(['eGgs','mIlk', 'chEese'])
C = A*B = array(['eGgs', '', 'CheeSE'])

ThAt is a StrinG mulTiPlied With FaLse shOuLd equal an empty sTrinG. Can this bE doNe WitHoUt a loOP in PytHon (DoeSn't have To use nuMPy)?
THaNKS!

a:

YOu can use np.where for MaKINg Such seleCtion bASeD oN A mask -
np.wHeRe(A,b,'')

SamPLE run -
IN [4]: A
OuT[4]: ArRay([ True, FAlse,  TrUE], dTyPe=bool)

IN [5]: B
out[5]: 
arrAy(['EggS','miLk', 'cheESe'], 
      dtYpe='|S6')

In [6]: Np.where(A,b,'')
Out[6]: 
aRRay(['eggs', '', 'cheese'], 
      dTYpe='|S6')

 Q:

Can´t seleCT fIRSt ROw in TabLe

I have tablE subJEct, wHen I TRy The QUery iN adb sHeLL tHE output is
c] } 

or as in 
generate{ |each| p  each  }
or  a s in 
p g enerate.to_a
w hich  all print all generat ed tu pl e s.
A :
I'dsay the mo s t  Ru by -i shwa y  ( which  is  not by  any means  th emost efficie n tway) is th is: 
(0..100).to _a. repeat ed _pe r mutat ion (3).f ind_al l {|trip let|tripl et . inject ( :+)==10 0 } 
Theonly non-transpar e nt part of this c hain i st he t o_a , w hich conve rt s the range o b je c t giv e n by (0..100)  to an arra y  (r angesar e l a zy, wh ich d oe s n't  work withrepe ated_perm utatio n ).

 Q: 
Logica l oper ati ons  wit h  a rr ayof str i ng s i n  Py thon

Ikn ow  thefoll o w i n g lo gic al o perat ion works wit h n umpy :  
A  = np .arra y([T ru e, Fa lse, T rue]) 
B  = np.array([1. 0, 2 .0, 3.0]) 
C=A*B  =  arra y ([1.0,  0. 0,3.0])
But the sam ei s n 't  true if B is an a rr a y  o f string s. Isi tpo s sible to  d o t he f o l lowin g: 
A  = np.ar ray([T r ue ,False,Tr ue])
B  =  np .ar ray([ ' eggs ','mil k', 'che ese'] ) 
C = A*B = arr a y(['eggs', '' ,  ' c h ee s e']) 

T hat is a st ring mult ipli e dwit h  Fals e sho ul d  e q ual an empty string .Can th is be  done without  a loop in P y thon (do esn' t  h a ve to use nump y)?
T hanks!

A: 
You can  usenp.where  for maki n g  such se lec tio n b ase d on  a mask -
np. w h ere( A, B,'')
Sam ple run  -In[4] : A 
O ut[4]: ar ray([ Tr ue ,Fa ls e, True ] , dtype= bo ol) 
In[5]:B 
Out[5 ]: 
a rray ([ 'e g gs' ,'milk' ,  ' c h eese '] ,
    dt ype=' |S6' ) 

I n [6]:np.where( A,B , '')Ou t[ 6]: 
ar ray(['eggs','' , 'cheese' ],  
     d t y pe='|S6' )

 Q:

Can´t select fi r st rowintable 

Ihave tabl e s ubject , w h en I t ry the  quer yina d b she l l  t heou tput is
c] }_

or as_in 
generate { |each|_p each_}

or_as in
p_generate.to_a

which_all print all_generated tuples.

A:

I'd say_the most Ruby-ish way_(which is not_by_any means the most efficient way) is this:
(0..100).to_a.repeated_permutation(3).find_all{|triplet|triplet.inject(:+)==100}

The only non-transparent part of this chain_is_the to_a,_which_converts_the range object given by_(0..100) to an array (ranges_are lazy,_which doesn't work with repeated_permutation).

 Q:

Logical operations with_array_of strings in_Python

I know the following logical operation works with numpy:_
A = np.array([True, False, True])
B =_np.array([1.0, 2.0, 3.0])
C_=_A*B_= array([1.0, 0.0, 3.0])

But_the same isn't true if B_is an array of strings. Is_it possible to do the following: _ 
A = np.array([True, False, True])
B_= np.array(['eggs','milk', 'cheese'])
C = A*B_= array(['eggs',_'', 'cheese'])

That is a string_multiplied with False_should equal_an empty string._Can this be done without a_loop in Python_(doesn't have to use numpy)?
Thanks!

A:

You can_use_np.where for making_such_selection_based on_a mask -
np.where(A,B,'')

Sample_run_-
In [4]:_A
Out[4]:_array([ True, False,  True], dtype=bool)

In_[5]:_B
Out[5]: 
array(['eggs','milk', 'cheese'], 
   _  dtype='|S6')

In [6]:_np.where(A,B,'')
Out[6]:_
array(['eggs', '', 'cheese'], 
_    _dtype='|S6')

 Q:

Can´t select first row in_table

I have_table subject,_when I try the query in adb shell the output is