Comparisment

   - compare programming languages by example

39

List cons

Place an element at the front of a linked list.

Created by sam

Add a new answer

Either add an answer for a new language or add an alternative solution.
A description is only necessary when the code is not suitably 'obvious' or to justify an alternative approach.

Haskell

lphabet :: [Char[
lphabet = ['b'..'z']

alphabet :: [Char]
alphabet = 'a' : lphabet

The cons operator ':' cons's a single element to a list.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.

Python

oneTwoThree = [1] + [2,3]

Append a single item.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.