forked from Orchid/orchid
Backup commit
My backspace key started ghosting. Nothing works atm.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import system::(io, fs, async)
|
||||
import std::(to_string, to_uint, inspect)
|
||||
|
||||
const folder_view := (path, next) => do{
|
||||
--[
|
||||
const folder_view_old := \path. do{
|
||||
cps println $ "Contents of " ++ fs::os_print path;
|
||||
cps entries = async::block_on $ fs::read_dir path;
|
||||
cps list::enumerate entries
|
||||
@@ -13,13 +14,13 @@ const folder_view := (path, next) => do{
|
||||
cps choice = readln;
|
||||
if (choice == "..") then do {
|
||||
let parent_path = fs::pop_path path
|
||||
|> option::unwrap
|
||||
|> option::assume
|
||||
|> tuple::pick 0 2;
|
||||
next parent_path
|
||||
} else do {
|
||||
let t[subname, is_dir] = to_uint choice
|
||||
|> (list::get entries)
|
||||
|> option::unwrap;
|
||||
|> option::assume;
|
||||
let subpath = fs::join_paths path subname;
|
||||
if is_dir then next subpath
|
||||
else do {
|
||||
@@ -30,8 +31,16 @@ const folder_view := (path, next) => do{
|
||||
}
|
||||
}
|
||||
}
|
||||
]--
|
||||
|
||||
const main := loop_over (path = fs::cwd) {
|
||||
cps path = folder_view path;
|
||||
const folder_view := \path. do cps {
|
||||
cps println $ "Contents of " ++ fs::os_print path;
|
||||
cps entries = async::block_on $ fs::read_dir path;
|
||||
let t[name, is_dir] = option::assume $ list::get entries 0;
|
||||
cps println $ to_string name ++ " " ++ fs::os_print is_dir
|
||||
}
|
||||
|
||||
const main := loop_over (path = fs::cwd) {
|
||||
cps folder_view path;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import std::to_string
|
||||
import std::conv::to_string
|
||||
|
||||
const fizz_buzz := n => (
|
||||
(recursive r (i=0) list::cons i $ r (i + 1))
|
||||
@@ -10,7 +10,7 @@ const fizz_buzz := n => (
|
||||
)
|
||||
|> list::take n
|
||||
|> list::reduce ((l, r) => l ++ "\n" ++ r)
|
||||
|> option::unwrap
|
||||
|> option::assume
|
||||
)
|
||||
|
||||
const main := fizz_buzz 100
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import std::exit_status
|
||||
import std::conv
|
||||
|
||||
const main := (
|
||||
const main2 := (
|
||||
println "Hello, world!"
|
||||
exit_status::success
|
||||
)
|
||||
-- main := "Hello, World!\n"
|
||||
|
||||
const main := conv::to_string t[1, 2, 3]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import std::to_string
|
||||
import std::conv::to_string
|
||||
|
||||
export const main := do{
|
||||
let foo = list::new[1, 2, 3, 4, 5, 6];
|
||||
@@ -7,7 +7,7 @@ export const main := do{
|
||||
|> list::skip 2
|
||||
|> list::take 3
|
||||
|> list::reduce ((a, b) => a + b)
|
||||
|> option::unwrap;
|
||||
|> option::assume;
|
||||
cps println $ to_string sum;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export const main := do{
|
||||
"bar" = 4
|
||||
];
|
||||
let num = map::get foo "bar"
|
||||
|> option::unwrap;
|
||||
|> option::assume;
|
||||
cps println $ to_string num;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import std::to_string
|
||||
import std::(conv, reflect)
|
||||
|
||||
const foo := t[option::some "world!", option::none]
|
||||
|
||||
@@ -18,4 +18,6 @@ const test2 := match bar {
|
||||
map::having ["is_alive" = true, "greeting" = foo] => foo
|
||||
}
|
||||
|
||||
const main := test2 ++ ", " ++ test1
|
||||
const tests := test2 ++ ", " ++ test1
|
||||
|
||||
const main := conv::to_string bar
|
||||
|
||||
Reference in New Issue
Block a user