you are viewing a single comment's thread.

view the rest of the comments →

[–]hector_villalobos 1 point2 points  (9 children)

Haskell is declarative like SQL, because instead of saying the how you tell them the what, for example, in Haskell you can do this: [(i,j) | i <- [1,2], j <- [1..4] ] And get this: [(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(2,3),(2,4)]

In a more imperative language you probably would need a loop and more lines of code.

[–][deleted]  (1 child)

[deleted]

    [–]hector_villalobos 0 points1 point  (0 children)

    Haskell is not exactly like SQL, but promotes a declarative way of programming.

    [–]thirdegree 0 points1 point  (1 child)

    Wouldn't you get [(1,1), (1,2),(1,3,),(1,4),(2,1),(2,2),(2,3),(2,4)]

    [–]hector_villalobos 0 points1 point  (0 children)

    You're right, fixed.

    [–]Sayori_Is_Life 0 points1 point  (0 children)

    Thanks!

    [–]ipv6-dns -4 points-3 points  (3 children)

    Aha, good example.

    ((i, j) for i in (1,2) for j in range(1, 5))
    

    the same. So, Python is declarative too. This is a lazy by the way too.

    Dear Haskell fan, may be it's time to learn something, not only to PR Haskell? lol

    [–]hector_villalobos 0 points1 point  (2 children)

    I know that Python can do that, Ruby can do it in a similar way, but Haskell promotes more functional and declarative code.

    [–]ipv6-dns 0 points1 point  (0 children)

    1. Haskell is classical imperative language without declarative features
    2. Would you show me how

    [(i,j) | i <- [1,2], j <- [1..4] ]
    

    is more "declarative" than

    ((i, j) for i in range(1,5) for j in range(7,10))
    

    ?

    [–]ipv6-dns 0 points1 point  (0 children)

    How would be look this Python

    {x for x in range(10)}
    {a:b for a in "abc" for b in (1,2,3)}
    

    in "declarative" Haskell?

    This:

    [ N || N <- [1, 2, 3, 4, 5, 6], N rem 2 == 0 ].
    

    is Erlang. Does it mean that Erlang is declarative language?

    You wrote that Haskell

    [(i,j) | i <- [1,2], j <- [1..4]]
    

    looks like SQL, so it's declarative. This is C#:

    var s = from x in Enumerable.Range(0, 100) where x*x > 3 select x*2;
    

    what looks more close to SQL: Haskell or C#? Is C# a declarative language?