Jump to content

Featured Replies

Posted

Hi,

is there the opposite of butlast ?

  • Author

in OM 2 ?

(butlast '(1 2 3 4 5))
=>(1 2 3 4)
(last '(1 2 3 4 5))
=>(5)
(butlast '(1 2 3 4 5) 1) 
=>(1 2 3 4)
(last '(1 2 3 4 5) 1)
=>(5)
(butlast '(1 2 3 4 5) 3)
=>(1 2)
(last '(1 2 3 4 5) 3)
=>(3 4 5)

 

or from the start

(nthcdr 2 '(1 2 3 4 5))
=>(3 4 5)
 

Jesper

 

If the opposite of butlast is "butfirst" then in plain lisp is:

 

(cdr '(1 2 3 4 5)) => (2 3 4 5)

or 

(subseq '(1 2 3 4 5) 1)

 

Achim

 

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy