A Discussion of Tuple Syntax

Timon Gehr timon.gehr at gmx.ch
Tue Aug 20 12:59:15 PDT 2013


On 08/20/2013 09:57 PM, Timon Gehr wrote:
> On 08/20/2013 05:18 PM, bearophile wrote:
>>>>>> s = "red blue"
>>>>>> (a, b) = s.split()
>>>>>> a
>>> 'red'
>>>>>> b
>>> 'blue'
>>
>> It's supported in Haskell too:
>>
>> Prelude> let s = "red blue"
>> Prelude> let [a, b] = words s
>> Prelude> a
>> "red"
>> Prelude> b
>> "blue"
>>
>> Bye,
>> bearophile
>
> Any language with algebraic data types supports this.

(Some will only allow it if you can prove the match is total within 
them, of course.)


More information about the Digitalmars-d mailing list