News for hackers. Stuff that matters.
Re:A Pythonista's Review of Haskell by sweeneyrod on Friday January 31, 2020 @06:06PM (#22206892)
> If you wanted to implement cons, car, and cdr in Python such that (cons (car "abc") (cdr "abc")) = "abc" you wouldn't be able to do it in the natural way

Sure you can!

    >>> car = lambda x: x[0]
    >>> cdr = lambda x: x[1:]
    >>> cons = lambda x, y: x + y
    >>> cons (car("abc"), cdr("abc"))
    'abc'
Re:A Pythonista's Review of Haskell by inimino on Saturday February 01, 2020 @01:34PM (#22212246)
But that cons is broken, such that you can't construct lists of strings.

For a correct implementation of cons, the following gives a list '("a" "b") of two strings:

    (cons "a" (cons "b" ()))
and (list "a" "b") is just sugar for the above. This doesn't work if you redefine cons on strings to mean concat.

In other words, if (cons "a" "bc") gives you "abc", then it's not cons.