News for hackers. Stuff that matters.
Re:Why it’s hard for programmers to write a program to flatt... by linkedlist007 on Friday February 24, 2017 @11:42AM (#13725212)
#python code

def flat(x):

  if type(x) == type([]) and len(x)==1:

    return flat(x[0])

  if type(x) == type([]) and len(x)>1:

    return flat(x[0]) + flat(x[1:])

  else:

    return [x]

There are no comments on this comment yet.