david Posted September 12 Share Posted September 12 Hi, is there the opposite of butlast ? Quote Link to comment Share on other sites More sharing options...
opmo Posted September 12 Share Posted September 12 Check the documents: List Operations. Quote Link to comment Share on other sites More sharing options...
david Posted September 12 Author Share Posted September 12 in OM 2 ? Quote Link to comment Share on other sites More sharing options...
jesele Posted September 12 Share Posted September 12 (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 opmo 1 Quote Link to comment Share on other sites More sharing options...
born Posted September 13 Share Posted September 13 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 opmo 1 Quote Link to comment Share on other sites More sharing options...
AM Posted September 13 Share Posted September 13 or (rest '(1 2 3 4 5)) => (2 3 4 5) or (extended) (car (cdr (cadr (cddr (nthcdr .... CLHS: Accessor CAR, CDR, CAAR, CADR, CDAR... CLHS.LISP.SE nthcdr (Programming in Emacs Lisp) WWW.GNU.ORG nthcdr (Programming in Emacs Lisp) opmo and Stephane Boussuge 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.