Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created September 7, 2022 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baweaver/8c82642be77f99c943ea474751f64e05 to your computer and use it in GitHub Desktop.
Save baweaver/8c82642be77f99c943ea474751f64e05 to your computer and use it in GitHub Desktop.
IDENTITY = -> v { v }
def proc_line(**fns)
fns.reduce(IDENTITY) { |fn, (m, args)|
fn >> m.to_proc.then { |m_proc| -> v { m_proc.call(v, *args) } }
}
end
[50, 100, 300, 5000].map(&proc_line(
to_s: 2, chars: nil, reverse: nil, join: nil, to_i: 2
))
# => [19, 19, 105, 569]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment