国外的题目:
写一个简短的程序,插入一个新的数值到一个排好序的表中。
假如: 已有表'(10000 9000 8000 7000 6000)
现在有一个新的记录,8500,要插入进来,变成表'(10000 9000 8500 8000 7000 )
维持表的长度不变,那个最小的被移走了。
如果新记录比表中元素都小,则表不变。
以下原文(我只是意译)
How to write the shortest lisp using mapcar or lambda to insert a value into a list. Say I have 5 scores - (list 10000 9000 8000 7000 6000). And a new high score of 8500 to insert into this list, meaning the result is 10000 9000 8500 8000 7000. Always end with 5 highest score only, notice the last item in the list 6000 is removed from the list. I have written a lisp but its quite long. I wondered if using mapcar or lambda will shorten the lisp ??