Re: Discuss changing the behaviour of append()

new topic     » goto parent     » topic index » view thread      » older message » newer message
gimlet said...

Just a question:

Assuming that appending/prepending to atoms is on
we have:

? append(1,{})  -- {1,{}} 
? append({},1)  -- {1} 
? prepend(1,{}) -- {{},1} 
? prepend({},1) -- {1} 

I'm not saying it's wrong but don't you find the difference strange?

No I don't, because the result is identical to when the first argument is a sequence ...

-- Ensuring that the first parameter is a sequence. 
? append({1},{})  -- {1,{}}  
? append({},1)  -- {1}  
? prepend({1},{}) -- {{},1}  
? prepend({},1) -- {1}  
 
-- Performing the 'equivalent' functionality using concatenate 
? {1} & {{}} 
? {} & {1} 
? {{}}& {1} 
? {1} & {} 

Or putting the operation into English text ...

  • Create a list such that the second argument is added, as a single element, to the set of elements in the first argument.
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu