0

I have an operation that outputs the list

{1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, 19, 20, 21, 
 22, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 61, 62, 63, 0}

I want it only to output the numbers greater than 0, is there a command or a short code to do this? I haven't been able to do it. Any suggestions are greatly appreciated.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
user40871
  • 9
  • 1
  • 2

1 Answers1

1

Example:

data = {1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, 19, 20, 21, \
22, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 59, 60, 61, 62, 63, 0}

Select[data, # > 0 &]

Reference:

Select

Guide:

Elements of Lists

e.doroskevic
  • 5,959
  • 1
  • 13
  • 32