Hi Tomas, I can accept your explanation, but then I think the docs should make it clear that the sorted list is what's returned by the function, and that the state of the "input list" afterwards can be somewhat unpredictable.
/Jon > Hi Jon, > >> (let L (3 2 5 4) (sort L) L) >> >> should give the same result as >> >> (let L (3 2 5 4) (sort L)) > > it should not;-) > >> Why couldn't L simply be given the same value? > > L is given the same value which you print in the first case. In the > second case, you printed out the return value of 'sort'. > > L still points to the same cons cell, but 'sort' modified the list > underneath. You'd have to do (setq L (sort L)) to get the sorted list > into the variable L. > > : (let L (3 2 5 4) (setq L (sort L)) L) > -> (2 3 4 5) > >> The docs on the 'sort' function says "Sorts lst by destructively >> exchanging its elements." > > That's correct. In your examples, L points to the first cons cell of > the list initially. However, 'sort' rearranges the list destructively > and that cons cell (pointed by L) is no longer the first one. > > Hope it helps, > > Tomas -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe