Zulip Chat Archive

Stream: lean4

Topic: find all lean files recursively


Arthur Paulino (Dec 14 2021 at 18:12):

I've written the following function to find all lean files in a directory:

partial def getFilePathsList (fp : FilePath) (acc : List FilePath := []) :
IO (List FilePath) := do
  if ← fp.isDir then
    let mut extra : List FilePath ← []
    for dirEntry in (← fp.readDir) do
      for innerFp in ← getFilePathsList dirEntry.path do
        extra ← extra.concat innerFp
    acc ++ extra
  else
    if (getFilePathExtension fp) = "lean" then
      acc.concat fp
    else
      acc

Is there something I can use out-of-the-box though?


Last updated: Feb 28 2026 at 14:05 UTC