This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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 = """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:io'; | |
| String elem(String tag, String text) { | |
| return '<$tag>$text</$tag>'; | |
| } | |
| String h1(String text) { | |
| return elem('h1', text); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typealias IO<T> = () -> T | |
| fun getChar(): IO<Char> { | |
| return { | |
| 'x' | |
| } | |
| } | |
| fun putChar(c: Char): IO<Unit> { | |
| return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (m >>= \x -> f x) >>= \x -> g x = m >>= \x -> (f x >>= \x -> g x) |
NewerOlder