| void foo(void (*a)(bool, bool), int b, int c, int d, int e) { | |
| a(b<c,d>(e)); | |
| } | |
| template <int, int> int b(int) { return 0; } | |
| template <int c, int d> void foo(void (*a)(int), int e) { | |
| a(b<c,d>(e)); | |
| } |
| Language | Syntax |
|---|---|
| Python | lambda x: x + 1 |
| JavaScript | x => x + 1 x => { return x + 1; } |
| TypeScript | (x: number): number => { return x + 1; } |
| Java | x -> x + 1 (int x) -> { return x + 1; } |
| Kotlin | { x -> x + 1 } { x: Int -> x + 1 } |
| Swift | { $0 + 1 } { x in x + 1 } { (x: Int) -> Int in return x + 1 } |
| Rust | |x| x + 1 |
| C++ | [](int x) -> int { return x + 1; } |
| #include <cstdlib> | |
| #include <atomic> | |
| #include <memory> | |
| template <class T> class Storage { | |
| T* storage; | |
| const std::size_t capacity; | |
| std::atomic<std::size_t> size; | |
| std::atomic<std::size_t> reference_count; | |
| public: |
| /** | |
| * You can edit, run, and share this code. | |
| * play.kotlinlang.org | |
| */ | |
| fun List<String>.iterate(f: (String) -> String) = map(f).joinToString(separator = "") | |
| fun main() { | |
| val fruits = listOf("apple", "strawberry", "banana") | |
| val html = """ |
| import 'dart:io'; | |
| String elem(String tag, String text) { | |
| return '<$tag>$text</$tag>'; | |
| } | |
| String h1(String text) { | |
| return elem('h1', text); | |
| } |
| typealias IO<T> = () -> T | |
| fun getChar(): IO<Char> { | |
| return { | |
| 'x' | |
| } | |
| } | |
| fun putChar(c: Char): IO<Unit> { | |
| return { |
| struct CFor<A, B, C>(A, B, C); | |
| impl<A, B, C> Iterator for CFor<A, B, C> where A: Clone, B: Fn(&A) -> bool, C: Fn(&mut A) { | |
| type Item = A; | |
| fn next(&mut self) -> Option<A> { | |
| if !self.1(&self.0) { | |
| return None; | |
| } | |
| let result = self.0.clone(); | |
| self.2(&mut self.0); |
| (m >>= \x -> f x) >>= \x -> g x = m >>= \x -> (f x >>= \x -> g x) |
| void gral_window_warp_cursor(struct gral_window *window, float x, float y) { | |
| NSRect window_rect = [[(GralWindow *)window contentView] convertRect:NSMakeRect(x, y, 0, 0) toView:nil]; | |
| NSRect screen_rect = [(GralWindow *)window convertRectToScreen:window_rect]; | |
| //CGWarpMouseCursorPosition(screen_rect.origin); | |
| CGPoint point = [[(GralWindow *)window contentView] convertPoint:NSMakePoint(x, y) toView:nil]; | |
| NSRect frame = [(GralWindow *)window frame]; | |
| point = CGPointMake(NSMinX(frame) + point.x, NSMaxY(NSScreen.screens[0].frame) - (NSMinY(frame) + point.y)); | |
| //CGPoint display_point = CGPointMake(NSMinX(frame) + window_point.x, NSMaxY(NSScreen.screens[0].frame) - (NSMinY(frame) + window_point.y)); | |
| CGWarpMouseCursorPosition(point); | |
| } |