1
0
Fork 0
forked from fun/fun

More examples documentation and just small fixes.

This commit is contained in:
Johannes Findeisen 2025-09-16 07:45:19 +02:00
commit 24f5f7517c
3 changed files with 65 additions and 1 deletions

View file

@ -0,0 +1,30 @@
#!/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
*/

View file

@ -67,3 +67,38 @@ for x in range(1, 3)
print(x + y) // expect: 2,3,3,4
print("=== for/range test end ===")
/*
=== for/range test start ===
0
1
2
3
4
2
3
4
5
6
2
3
3
4
=== for/range test end ===
=== for/range test start ===
0
1
2
3
4
2
3
4
5
6
2
3
3
4
=== for/range test end ===
*/