removing last element of a list(scheme)

后端 未结 6 859
忘了有多久
忘了有多久 2021-02-07 18:17

So I have to remove the last element of a list in scheme.

For example, let\'s say I have a list (1 2 3 4). I need to return:

(1 2 3)
         


        
6条回答
  •  深忆病人
    2021-02-07 18:37

    SRFI 1 (activate in Racket using (require srfi/1)) has a drop-right function:

     (drop-right '(1 2 3 4) 1)   ; => (1 2 3)
    

提交回复
热议问题