October 27, 2008
Bill Baxter wrote:
> On Mon, Oct 27, 2008 at 10:16 AM, Bent Rasmussen
> <IncredibleShrinkingSphere@gmail.com> wrote:
>> Agreed.
>>
>> As an example: what domain does not include boolean expressions? And how
>> many domains include vector and matrix operations? Quite many.
> 
>> It would be a massive boost for readability in those domains (and in all
>> domains, with boolean expressions).
> 
> I don't know about you, but to me 'and' and 'or' make for much more
> readable boolean expressions than the standard mathematical symbols ^
> and v.  Heck, && and || are more readable to me than the math symbols.

Hm, in my experimental emacs shenanigans I had && displayed as a wedge and || displayed as a vee and heck do they look good.

>> The problem is not the operators themselves; a language does not loose
>> anything by extension, it is how exactly to best arrive at the goal of
>> having the code look nice and readable with those operators.
>>
>> - Bent
>>
>> Hm, anyone fancy the |> operator?
> 
> What would that mean?

Ironic smile with eyes closed.


Andrei
October 27, 2008
On Mon, Oct 27, 2008 at 11:46 AM, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
> Bill Baxter wrote:
>>
>> On Mon, Oct 27, 2008 at 10:16 AM, Bent Rasmussen <IncredibleShrinkingSphere@gmail.com> wrote:
>>>
>>> Agreed.
>>>
>>> As an example: what domain does not include boolean expressions? And how many domains include vector and matrix operations? Quite many.
>>
>>> It would be a massive boost for readability in those domains (and in all domains, with boolean expressions).
>>
>> I don't know about you, but to me 'and' and 'or' make for much more readable boolean expressions than the standard mathematical symbols ^ and v.  Heck, && and || are more readable to me than the math symbols.
>
> Hm, in my experimental emacs shenanigans I had && displayed as a wedge and || displayed as a vee and heck do they look good.

Hmm.  I guess it's just because I've spent a lot more time looking at the C operators than the math ones.

--bb
October 27, 2008
Not quite

http://blogs.msdn.com/dsyme/archive/2008/09/01/the-f-operators-and-basic-functions.aspx

|> is pipelining
>> is function composition

- Bent

"Andrei Alexandrescu" <SeeWebsiteForEmail@erdani.org> skrev i meddelelsen news:ge3a2o$2i0k$2@digitalmars.com...
> Bill Baxter wrote:
>> On Mon, Oct 27, 2008 at 10:16 AM, Bent Rasmussen
>> <IncredibleShrinkingSphere@gmail.com> wrote:
>>> Agreed.
>>>
>>> As an example: what domain does not include boolean expressions? And how
>>> many domains include vector and matrix operations? Quite many.
>>
>>> It would be a massive boost for readability in those domains (and in all
>>> domains, with boolean expressions).
>>
>> I don't know about you, but to me 'and' and 'or' make for much more
>> readable boolean expressions than the standard mathematical symbols ^
>> and v.  Heck, && and || are more readable to me than the math symbols.
>
> Hm, in my experimental emacs shenanigans I had && displayed as a wedge and || displayed as a vee and heck do they look good.
>
>>> The problem is not the operators themselves; a language does not loose
>>> anything by extension, it is how exactly to best arrive at the goal of
>>> having the code look nice and readable with those operators.
>>>
>>> - Bent
>>>
>>> Hm, anyone fancy the |> operator?
>>
>> What would that mean?
>
> Ironic smile with eyes closed.
>
>
> Andrei 

October 27, 2008
This is a matter of taste and habbit, but my preference is

(A1) ¬(p ʌ q)

(A2) not (p and q)

(A3) !(p && q)

Eiffel also uses (A2) and it looks much better than (A3).

Still, in my oppinion your preference is still better than the status quo. Also, consider

(B1) p ≠ (d ≤ q)

Relational operators also look much better and look more homogeneous and consistent with logical operators in (A1).

- Bent

"Bill Baxter" <wbaxter@gmail.com> skrev i meddelelsen news:mailman.289.1225071455.3087.digitalmars-d@puremagic.com...
> On Mon, Oct 27, 2008 at 10:16 AM, Bent Rasmussen
> <IncredibleShrinkingSphere@gmail.com> wrote:
>> Agreed.
>>
>> As an example: what domain does not include boolean expressions? And how
>> many domains include vector and matrix operations? Quite many.
>
>> It would be a massive boost for readability in those domains (and in all
>> domains, with boolean expressions).
>
> I don't know about you, but to me 'and' and 'or' make for much more
> readable boolean expressions than the standard mathematical symbols ^
> and v.  Heck, && and || are more readable to me than the math symbols.
>
>> The problem is not the operators themselves; a language does not loose
>> anything by extension, it is how exactly to best arrive at the goal of
>> having the code look nice and readable with those operators.
>>
>> - Bent
>>
>> Hm, anyone fancy the |> operator?
>
> What would that mean?
>
> --bb 

October 27, 2008
Andrei Alexandrescu wrote:
>> I don't know about you, but to me 'and' and 'or' make for much more
>> readable boolean expressions than the standard mathematical symbols ^
>> and v.  Heck, && and || are more readable to me than the math symbols.
> 
> Hm, in my experimental emacs shenanigans I had && displayed as a wedge and || displayed as a vee and heck do they look good.

I'm sure it has to do with what you're used to looking at. I forget which one is which (heck, I was forgetting which was which even when I was taking a logic class). However, & for "and" has a precedent in natural language. | for "or" is a bit out there, but at least it looks significantly different than &, which cannot be said about ^/v.
October 27, 2008
Bent Rasmussen wrote:
> Not quite
> 
> http://blogs.msdn.com/dsyme/archive/2008/09/01/the-f-operators-and-basic-functions.aspx 
> 
> 
> |> is pipelining
>>> is function composition
> 
> - Bent
> 
> "Andrei Alexandrescu" <SeeWebsiteForEmail@erdani.org> skrev i meddelelsen news:ge3a2o$2i0k$2@digitalmars.com...
>> Bill Baxter wrote:
>>> On Mon, Oct 27, 2008 at 10:16 AM, Bent Rasmussen
>>> <IncredibleShrinkingSphere@gmail.com> wrote:
>>>> Agreed.
>>>>
>>>> As an example: what domain does not include boolean expressions? And how
>>>> many domains include vector and matrix operations? Quite many.
>>>
>>>> It would be a massive boost for readability in those domains (and in all
>>>> domains, with boolean expressions).
>>>
>>> I don't know about you, but to me 'and' and 'or' make for much more
>>> readable boolean expressions than the standard mathematical symbols ^
>>> and v.  Heck, && and || are more readable to me than the math symbols.
>>
>> Hm, in my experimental emacs shenanigans I had && displayed as a wedge and || displayed as a vee and heck do they look good.
>>
>>>> The problem is not the operators themselves; a language does not loose
>>>> anything by extension, it is how exactly to best arrive at the goal of
>>>> having the code look nice and readable with those operators.
>>>>
>>>> - Bent
>>>>
>>>> Hm, anyone fancy the |> operator?
>>>
>>> What would that mean?
>>
>> Ironic smile with eyes closed.
>>
>>
>> Andrei 
> 

I thought |> is a ket vector in quantum mechanics.

<ϕ|A|ψ> := ∫ ϕ(x)* A ψ(x) dx
October 27, 2008
Bent Rasmussen wrote:
> http://blogs.msdn.com/dsyme/archive/2008/09/01/the-f-operators-and-basic-functions.aspx 
> 
> 
> |> is pipelining
>>> is function composition

So what's the difference? That is to say, what would tolower(trim(str)) translate to?
October 27, 2008
"Robert Fraser" <fraserofthenight@gmail.com> skrev i meddelelsen news:ge3mit$i33$1@digitalmars.com...
> So what's the difference? That is to say, what would tolower(trim(str)) translate to?

It would translate to something like

val x = str |> trim |> tolower;

So it looks like a pipeline. And to construct such a function, you'd define it as

val f = trim >> tolower;
val x = str |> f;

This is from memory, I don't program in F#.

- Bent



October 27, 2008
Robert Fraser escribió:
> Andrei Alexandrescu wrote:
>>> I don't know about you, but to me 'and' and 'or' make for much more
>>> readable boolean expressions than the standard mathematical symbols ^
>>> and v.  Heck, && and || are more readable to me than the math symbols.
>>
>> Hm, in my experimental emacs shenanigans I had && displayed as a wedge and || displayed as a vee and heck do they look good.
> 
> I'm sure it has to do with what you're used to looking at. I forget which one is which (heck, I was forgetting which was which even when I was taking a logic class). However, & for "and" has a precedent in natural language. | for "or" is a bit out there, but at least it looks significantly different than &, which cannot be said about ^/v.

You can remember those symbols by remembering that U is Union, and "inverted U" is intersection. Now U points to the same place as v, and "inverted U" points to the same place as ^, and "union/or", "intersection/and" are similar concepts.
October 27, 2008
Bent Rasmussen wrote:
> "Robert Fraser" <fraserofthenight@gmail.com> skrev i meddelelsen news:ge3mit$i33$1@digitalmars.com...
>> So what's the difference? That is to say, what would tolower(trim(str)) translate to?
> 
> It would translate to something like
> 
> val x = str |> trim |> tolower;
> 
> So it looks like a pipeline. And to construct such a function, you'd define it as
> 
> val f = trim >> tolower;
> val x = str |> f;
> 
> This is from memory, I don't program in F#.

BTW, incidentally std.functional defines both operators in prefix form:

auto x = pipe!(trim, tolower)(str);

or

auto x = compose!(tolower, trim)(str);


Andrei
1 2
Next ›   Last »