POV-Ray : Newsgroups : povray.off-topic : Why is Haskell interesting? : Re: Why is Haskell interesting? Server Time
4 Sep 2024 19:19:13 EDT (-0400)
  Re: Why is Haskell interesting?  
From: nemesis
Date: 27 Feb 2010 23:20:01
Message: <web.4b89ee9bb2efd7406d01b7150@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Darren New <dne### [at] sanrrcom> wrote:
> > I think c ! 2 is the third element of c, not unlike c[2].
>
>   [] is used almost universally for indexing in most languages (not only
> for random access of arrays, but also eg. accessing relational sets (where
> the thing inside the square brackets is the key and the return value is the
> data)). Is there a logical reason why Haskell chooses an odd syntax of
> "x ! y" for the same thing than most other languages express as "x[y]"?
>
>   Using ! for the nth element is not very expressive. In mathematics ! is
> usually used for factorials, in many programming languages it's used to
> express logical negation (granted, not a very logical choice per se, but
> quite established), and in natural languages it's used to express shouting
> or to emphasize the importance of something (like "WARNING!").

Like Scheme using it to warn about bad imperative constructs, like (set! v 1) :)

>   So why choose ! as "the nth element"?

v!1 is briefer than v[1] :)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.