Algorithmic:1.0.0 - Typesetting algorithms has never been more easy!

I am excited to show-off the v1 of algorithmic!
This is a package inspired by the LaTeX algorithmicx package for Typst. It’s useful for writing pseudocode and typesetting it all nicely.

I am taking over as maintainer after Jade. The project has been transferred to the Typst community, contributions are very much welcome :smiley: !

I really the DSL approach inspired by cetz, which is why I reached out to Jade to see whether she had any interest in passing on the project (it was unmaintained) in order to keep the name of the package.
This is not yet released on the universe, but soon to be ;)

#import "@preview/algorithmic:1.0.0"
#import algorithmic: style-algorithm, algorithm-figure
#show: style-algorithm

#algorithm-figure({
  import algorithmic: *
  Procedure(
    "Binary-Search",
    ("A", "n", "v"),
    {
      Comment[Initialize the search range]
      Assign[$l$][$1$]
      Assign[$r$][$n$]
      LineBreak
      While(
        $l <= r$,
        {
          Assign([mid], FnInline[floor][$(l + r) / 2$])
          IfElseChain(
            $A ["mid"] < v$,
            {
              Assign[$l$][$m + 1$]
            },
            [$A ["mid"] > v$],
            {
              Assign[$r$][$m - 1$]
            },
            Return[$m$],
          )
        },
      )
      Return[*null*]
    },
  )
})
9 Likes