This file contains 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
use std::fmt::Debug; | |
#[derive(Debug,Clone)] | |
enum ListOrElement<T> | |
where T: Debug + Clone { | |
List(Vec<ListOrElement<T>>), | |
Element(T) | |
} | |
impl <T: Debug + Clone> ListOrElement<T> { |
This file contains 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
package flatten; | |
import java.util.Optional; | |
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
public class Either<L, R> { | |
private final Optional<L> left; | |
private final Optional<R> right; |
This file contains 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
package flatten; | |
import java.util.Arrays; | |
import java.util.stream.IntStream; | |
public class Flatten2 { | |
public static void main(String[] args) { | |
Object[] input = new Object[] { 1, new Object[] { 2, 3 }, new Object[] { 4, new Object[] { 5, 6 } } }; | |
System.out.println(Arrays.deepToString(input)); |
This file contains 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
package flatten; | |
import java.util.Arrays; | |
import java.util.Optional; | |
import java.util.OptionalInt; | |
import java.util.function.Function; | |
import java.util.function.IntFunction; | |
import java.util.stream.IntStream; | |
public class ArrayOrInt { |
This file contains 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
package uk.co.zootm.whee | |
trait Adder[L,R,O] { | |
def add( l: L, r: R ): O | |
} | |
class One | |
object Adder { | |
class Addable[L]( val l: L ) { |