Elegant get non empty list or [[]] (default value) in haskell

后端 未结 0 1153
感动是毒
感动是毒 2021-01-23 15:43

Is it possible to simplify the definition of this function, which returns [[]] if l is empty and l otherwise?

f l = if l == [] then [[]] else l

f

相关标签:
回答
  • 消灭零回复
提交回复
热议问题