These are chat archives for evhub/coconut

10th
Sep 2017
i-s-o-g-r-a-m
@i-s-o-g-r-a-m
Sep 10 2017 21:39
docs say Additionally, all pipe operators support a lambda as the last argument, despite lambdas having a lower precedence. Thus, 10 |> x -> x**2 is valid, though the body of the lambda will still capture all following pipe operators.
but I don't see any mention of this, which is seeming to work for me:
(
    read_file(sys.argv[1])
    ↦ .lower()
    ↦ re.compile('[\W_]+').sub$(' ')
    ↦ .split()
    ↦ (s → [w for w in s if w not in stop_words()])
    ↦ print
)
parens appear to be necessary there, right?
should there be a mention of this in the Pipeline part of the docs?
Evan Hubinger
@evhub
Sep 10 2017 23:13

@i-s-o-g-r-a-m If you omit the parens, as in

(
    read_file(sys.argv[1])
    ↦ .lower()
    ↦ re.compile('[\W_]+').sub$(' ')
    ↦ .split()
    ↦ s → [w for w in s if w not in stop_words()]
    ↦ print
)

it becomes equivalent to

(
    read_file(sys.argv[1])
    ↦ .lower()
    ↦ re.compile('[\W_]+').sub$(' ')
    ↦ .split()
    ↦ (s → [w for w in s if w not in stop_words()] ↦ print)
)
which should actually do the same thing, so the parens aren't necessary