Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define g ⨟ f = f ∘ g #34832

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Define g ⨟ f = f ∘ g #34832

wants to merge 2 commits into from

Conversation

tkf
Copy link
Member

@tkf tkf commented Feb 21, 2020

This PR adds a simple definition ⨟(fs...) = ∘(reverse(fs)...) to the new operator added in #34722. This is useful for abstracting out pipelined operations like x |> f |> g |> h as f ⨟ g ⨟ h. For example:

mapping(f) = xs -> Base.Generator(f, xs)
filtering(f) = xs -> Iterators.filter(f, xs)
partitioning(n) = xs -> Iterators.partition(xs, n)
using Base.Iterators: flatten

# Iterator-to-iterator transformation to do some normalization and filtering
# with sliding window (a toy example):
ixf = partitioning(10) 
    mapping(x -> (x , mean(x))) 
    filtering(((_, m),) -> m > 0) 
    mapping(((x, m),) -> x ./ m) 
    flatten

collect(ixf(randn(100)))

cc @jw3126 @schlichtanders @ararslan

@ararslan
Copy link
Member

I don't know what the symbol is

image

@tkf
Copy link
Member Author

tkf commented Feb 21, 2020

In my browser:

image

@ararslan
Copy link
Member

Char(0x2a1f) doesn't render in my terminal either (same system: Ubuntu derivative). It'd be difficult for me to believe I'd be the only one with this issue, so it's difficult to support adding something I can only read in other people's screenshots. 😛

@tkf
Copy link
Member Author

tkf commented Feb 22, 2020

I just learnt from #34835 (comment) that fileformat.info shows a list of fonts that supports a given unicode (within the fonts installed in their server). Maybe useful as sampling points:

So yes, U+2218 definitely is supported by more fonts than U+2A1F.

FYI here is the list of non-ASCII names exported from Base:

julia> [x for x in (string(x) for x in names(Base)) if !isascii(x)]
26-element Array{String,1}:
 "÷"
 "π"
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""
 ""

There are some variations in font support for these unicode characters. For example, U+212F is supported less than U+2218 but more than U+2A1F :

@laborg
Copy link
Contributor

laborg commented Feb 22, 2020

I can confirm that this is not shown on a vanilla ubuntu + firefox setup. IMHO the short list of supported fonts is good to estimator for the amount of confusion to expect from adding this.

@Keno
Copy link
Member

Keno commented Feb 23, 2020

Somebody should file a request with whatever authority is in charge of font authoring for that combination ;).

@andyferris
Copy link
Member

I agree an operator with this semantic would be great; unfortunately, I also don't see this rendered correctly (in my browser or terminal).

@jlapeyre
Copy link
Contributor

Maybe it's an ubuntu quirk. It's rendered in my browsers and terminals. I'm running Arch, which doesn't give you anything out of the box.

@JeffBezanson
Copy link
Member

I knew you were up to something when you added this to the parser :)

Works fine for me on two ubuntu 18.04 systems. I hesitate to add an operator with potentially poor font coverage to Base though.

@jw3126
Copy link
Contributor

jw3126 commented Feb 25, 2020

Works for me on ubuntu 18.04 + firefox

@tkf
Copy link
Member Author

tkf commented Feb 25, 2020

Of courses, we can solve the font problem by defining something with ASCII :trollface:

@schlichtanders
Copy link

font is correctly displayed for me on mac catalina 10.15.2 with all three, chrome, firefox and safari, with default font settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants