Skip to content

Commit

Permalink
fixes examples and std after lambda change (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
kritzcreek authored Oct 6, 2024
1 parent 061002e commit 1266769
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions playground/examples/closure.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ fn main() -> i32 {
}

fn twice[a](f : fn(a) -> a) -> fn (a) -> a {
fn (x : a) -> a {
f(f(x))
}
\(x) { f(f(x)) }
}
4 changes: 2 additions & 2 deletions playground/examples/histogram.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ fn tick(time_elapsed_ms: f32) -> unit {
if frame_timer > 100.0 {
set frame_timer = 0.0;
clear();
let generator = fn() -> i32 { random_int(0, 99) };
let generator = \() -> i32 { random_int(0, 99) };
let buckets = histogram(10, generator);
render_canvas(buckets)
} else {}
}

fn main() {
let generator = fn() -> i32 { random_int(0, 99) };
let generator = \() -> i32 { random_int(0, 99) };
let buckets = histogram(10, generator);
render(buckets)
}
Expand Down
4 changes: 2 additions & 2 deletions playground/examples/lambda.nemo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn main() -> i32 {
let x = 1;
let f = fn (y : i32) -> i32 {
let f = \(y : i32) -> i32 {
y + x
};
f(2)
}
}
2 changes: 1 addition & 1 deletion playground/examples/list.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Both via recursion and imperative style.
fn main() {
let list = range(0, 10);
let squared = map#[i32, i32](fn (x : i32) -> i32 { x * x }, list);
let squared = map#[i32, i32](\(x) { x * x }, list);
for_each#[i32](log, squared);
log(sum(squared))
}
Expand Down
4 changes: 2 additions & 2 deletions playground/examples/strings.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct MutBox[a] {
// An iterator over the codepoints in a utf8 string
fn chars(bs : bytes) -> fn () -> Option[i32] {
let offset = MutBox { value = 0 };
fn () -> Option[i32] {
\() {
if offset.value == bytes_len(bs) {
Option::None {}
} else {
Expand Down Expand Up @@ -168,7 +168,7 @@ fn str_new(buf : bytes) -> Str {

fn str_chars(s : Str) -> fn () -> Option[i32] {
let offset = MutBox { value = s.offset };
fn () -> Option[i32] {
\() {
if offset.value >= s.offset + s.len {
Option::None {}
} else {
Expand Down
2 changes: 1 addition & 1 deletion std/string.nemo
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn unsafe_new(buf : bytes) -> Str {

fn chars(s : Str) -> fn () -> option::Option[i32] {
let offset = MutBox { value = s.offset };
fn () -> option::Option[i32] {
\() {
if offset.value >= s.offset + s.len {
option::Option::None {}
} else {
Expand Down

0 comments on commit 1266769

Please sign in to comment.