Advertisement
samham1218

Lisp functions

Nov 17th, 2018
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. Write a function remv to remove list elements from a list (single elements or lists). ex: (remv '(a b) '(a b) c)) -> (a b c)
  2.  
  3. Write a function remv_dub to remove duplicate elements (single elements or lists) from a list. ex: (remv_dub '(a b (a) c b (a))) -> (a b c (a)))
  4.  
  5. Write a function lists to return the list elements of a list. ex: (lists '(1 (2 3) (4) 5)) -> ((2 3) (4))
  6.  
  7. Write a function sec_min to return the second smallest integer in a list. ex: (sec_min '(1 3 2 5 4)) -> 2
  8.  
  9. Write a function tri that will determine whether an integer is a triangular number (the formula (n*(n-1)/2) must not be used). ex: (tri 21) -> T
  10.  
  11. Write a function perm to generate the permutations of the identity list from 1 to n. The higher order function mapcar will be useful. ex: (perm'(3)) -> ((1 2 3) (2 1 3) (2 3 1) (1 3 2) (3 1 2) (3 2 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement