I want to recreate the match-with construct typical in functional programming languages using the algorithm2e package. I've found that \SetKwSwitch gets me most of the way there, but it forces the 'do' to be the same for the switch and the case statements.
This is my code:
\documentclass{article} \usepackage[linesnumbered,lined,ruled]{algorithm2e} \begin{document} \begin{figure} \begin{algorithm}[H] \DontPrintSemicolon \SetKwSwitch{Match}{MatchCase}{MatchOther}{match}{with}{|}{\_}{}{end} \Match{a}{ \lMatchCase{4}{Some 1\;} \lMatchCase{8}{Some 2\;} } \end{algorithm} \end{figure} \end{document} What I get is something like:
match a with | 4 with Some 1 | 8 with Some 2 end What I'd like is:
match a with | 4 => Some 1 | 8 => Some 2 end 