;;Basic implementation of operations on persistent lists: concatenation and update element.(defnmy-concat[xsys](if(empty?xs)ys(cons(firstxs)(my-concat(restxs)ys))))(defnmy-update[xsnys](cond(empty?xs)(throw(Exception."Can't change empty list!"))(=n0)(consys(restxs)):else(cons(firstxs)(my-update(restxs)(decn)ys))))(deflst'(ABC))(deflst1'(DEF))(my-concatlstlst1);;=>(A B C D E F)(my-updatelst12'Z);;=>(D E Z)lst;;=> (A B C)lst1;;=>(D E F)
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.