0
$\begingroup$

I have this list

preRowLocalizer[27]={Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, \
Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, {0, 0, 0, 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   1, 0, 0, 0, 0, 
  0}, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, \
Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, Null, \
Null, Null, Null, Null, Null}

But I want to get only the element of the form

{0,....,0,1,0,...,0}

I tried using the command Select[preRowLocalizer[27], # != Null], but it is not giving me any output. Does anyone know why this is happening?

$\endgroup$
  • 2
    $\begingroup$ Use =!= instead of !=, and report back. $\endgroup$ – J. M. is away May 29 '16 at 19:38
  • $\begingroup$ I tried that and it is giving me only an empty set {}. $\endgroup$ – juyo May 29 '16 at 19:41
  • $\begingroup$ Select[list, # =!= Null &] works for me; what did you put in? $\endgroup$ – J. M. is away May 29 '16 at 19:42
  • $\begingroup$ With the additional & works, do you know why that is needed? $\endgroup$ – juyo May 29 '16 at 19:44
  • $\begingroup$ Look at the docs for Select[]; pay attention to the "Basic Examples". $\endgroup$ – J. M. is away May 29 '16 at 19:46
0
$\begingroup$
First[DeleteCases[preRowLocalizer[27], Null]]

First[preRowLocalizer[27] /. Null -> Nothing]

First[Cases[preRowLocalizer[27], _List]]

All the above give

{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.