tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

28 lignes · 820 octetsBrut · Historique
1// Directory listing (std/file, issue #179): the crate's own directory
2// holds its manifest and sources; a missing path is an `Error`, not a
3// panic. The entries' order is unspecified, so only membership is
4// checked. (Both backends run this with the crate's directory as the
5// working directory.)
6
7import std/file
8import std/io
9import std/list
10
11pub fn main :: -> () / <io>
12{
13 match file.list_dir "."
14 { Ok(entries) ->
15 {
16 io.println (show (list.any entries fn e { e == "Cargo.toml" }))
17 io.println (show (list.any entries fn e { e == "src" }))
18 io.println (show (list.any entries fn e { e == "." }))
19 }
20 , Error(e) -> io.println e
21 }
22 match file.list_dir "/definitely/not/here"
23 { Ok(_) -> io.println "unexpected", Error(_) -> io.println "Error" }
24}
25//> True
26//> True
27//> False
28//> Error