Code golf: combining multiple sorted lists into a single sorted list

前端 未结 26 2052
余生分开走
余生分开走 2020-12-29 12:42

Implement an algorithm to merge an arbitrary number of sorted lists into one sorted list. The aim is to create the smallest working programme, in whatever language you like.

26条回答
  •  被撕碎了的回忆
    2020-12-29 12:59

    F#, 32 chars

    let f x=List.sort(List.concat x)
    

    And without using a built in function for the concat (57 chars):

    let f x=List.sort(Seq.toList(seq{for l in x do yield!l}))
    

提交回复
热议问题