Fork me on GitHub
#core-async
<
2017-03-21
>
noisesmith00:03:18

you can provide (map f) as an optional arg when creating the channel

johanatan00:03:37

the channel is being created by sql/select from sqlingvo

noisesmith00:03:47

or, if you don’t control channel creation, you can pipe into your channel

johanatan00:03:07

can you explain what you mean by "pipe into your channel"?

noisesmith00:03:28

it takes a from channel and a to channel

noisesmith00:03:35

put the (map f) transducer on the to channel

noisesmith00:03:52

or even pipeline with an xf arg maybe?

johanatan00:03:11

yea, i thought about pipeline but it feels like an abuse of the semantics

noisesmith00:03:18

I would go with pipe though, less complex

johanatan00:03:29

how do i know a good buf-or-n to pick for the arg to chan?

noisesmith00:03:31

pipe plus a chan with a transducer does what you want

noisesmith00:03:41

nil is equivalent to chan with no args

johanatan00:03:50

ahh, right. ok, cool

johanatan00:03:05

this seems like something common enough that it should be in the std lib though honestly

noisesmith00:03:15

pipe is in the stdlib

johanatan00:03:26

not pipe. the whole construct that i'm going to build here

johanatan00:03:45

a) create a chan passing xfm, b) call pipe with orig chan and newly created chan from a

johanatan00:03:52

seems like a super common operation

johanatan00:03:12

one i would've expected to have the name map actually 🙂

noisesmith00:03:52

johanatan map> exists, and is explicitly deprecated in favor of using a map transducer as we’ve just described

noisesmith00:03:05

so it exists, but authors think you shouldn’t use it any more

johanatan00:03:11

ahh, yea, i figured that's what that was but since it's deprecated there's no documentation explaining what it is

johanatan00:03:46

well, not using it amounts to me re-writing it in the form of a helper that calls the transducer way

johanatan00:03:51

so, not really any benefit that i can see

noisesmith00:03:54

oh wait, core.async/map still exists, is not deprecated, and directly does what you want

johanatan00:03:02

no, that takes N channels

johanatan00:03:09

I have only 1 channel with N things

noisesmith00:03:23

map also maps over n collections

noisesmith00:03:29

usually n is 1, but it’s still n

johanatan00:03:43

ahh, then i know my problem

noisesmith00:03:02

(async/map f [c]) should work

johanatan00:03:09

i tried calling it like: (map :a-kwd src-channel) rather than (map :a-kwd [src-channel])

noisesmith00:03:48

I always do that when I’m using alts!