How do I reverse the `cases` function?

218 Views Asked by At

I would like to do the opposite of cases. Instead of this:
cases
(which is given by $ f(x) = cases(g(x), h(x)) $)

I want this:
sesac

1

There are 1 best solutions below

0
On BEST ANSWER

I was able to accomplish my goal by creating the following function:

#let sesac(..arr, spacing: 6pt) = {
  box($ lr(#stack(dir: ttb, spacing: spacing, ..arr.pos().map(item => align(left, $ #item $))) }) $, )
}

and using it like so:
$ sesac(g(x), h(x)) = f(x) $)

to get
sesac

I called it "sesac", since that's "cases" spelled backwards.

In the case where you need to align the equations on the left (or right) side, I also made sesac2:
#let sesac2(l, r) = $ lr(#box(l) }) #box(r) $

Used as follows:

#sesac2($ g(x) \
          h(x) $, $ f(x) $)

(It produces very similar output)