1
0
Fork 0
forked from fun/fun
fun/examples/file_print_for_file_line_by_line.fun
2025-09-16 09:06:44 +02:00

31 lines
665 B
Standard ML
Executable file

#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://hanez.org/project/fun/
*
* Copyright 2025 Johannes Findeisen <you@hanez.org>
* Licensed under the terms of the ISC license.
* https://opensource.org/license/isc-license-txt
*/
print("=== Line-by-line print start ===")
string file = "/etc/passwd"
// Print each line in a file
fun print_file_lines(path)
content = read_file(path)
lines = split(content, "\n")
for line in lines
print(line)
print("Printing file: " + file)
print_file_lines(file)
print("=== Line-by-line print end ===")
/* Expected output:
? The content of /etc/passwd
Like: cat /etc/passwd
*/