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
| Implement a function, routine or method (and the support code you might need) that simulates 6 tosses of 3 coins | |
| each and outputs a string according to the Value Rules below. | |
| Value Rules | |
| a) Tails has a value of 2, and heads a value of 3. | |
| b) Getthetotalvalueofthethreecoinspertoss. | |
| c) Compose a string with these values in reverse order, from toss 6 to 1. Example output: “767777” | |
| val r = scala.util.Random |
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
| object JsonParsing extends App { | |
| import org.json4s._ | |
| import org.json4s.jackson.JsonMethods._ | |
| import org.json4s.JsonDSL._ | |
| implicit val formats = DefaultFormats | |
| println(parse( """ { "numbers" : [1, 2, 3, 4] } """)) | |
| println(parse( """{"name":"Toy","price":35.35}""", useBigDecimalForDouble = true)) |
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
| package test; | |
| import java.time.Duration; | |
| import java.time.Instant; | |
| import java.time.temporal.ChronoUnit; | |
| import java.util.Random; | |
| import java.util.concurrent.*; | |
| import java.util.function.Function; |
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
| package com.example; | |
| import java.io.IOException; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.function.Predicate; | |
| public class MessingAround { |
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
| package com.example; | |
| import java.io.IOException; | |
| import java.util.function.Function; | |
| public class MessingAround { | |
| public static void main(String[] args) throws IOException, InterruptedException { |
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
| package com.example; | |
| import java.io.IOException; | |
| import java.time.Duration; | |
| import java.time.Instant; | |
| import java.util.function.Supplier; | |
| public class MessingAround { |
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
| package com.example; | |
| import java.io.IOException; | |
| import java.util.List; | |
| import java.util.stream.Collectors; | |
| import java.util.stream.IntStream; | |
| import java.util.stream.Stream; | |
| public class MessingAround { |
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
| sleeping=1 | |
| if [ "$1" != "" ]; then | |
| sleeping=$1 | |
| fi | |
| echo " (___)" | |
| echo " (o o)____/" | |
| echo " @@ \\" | |
| echo " \ ____, /" | |
| echo " // //" |
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
| Arrays.stream(e.getStackTrace()).limit(5L).map(stackEl -> " " + stackEl).collect(Collectors.joining("\n"))); |
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
| trait Combinable[T]{ | |
| def combine(a:T,b:T):T | |
| } | |
| object Combinable{ | |
| def apply[T](implicit c:Combinable[T]) = c | |
| trait CombinableOps[T]{ | |
| def self:T | |
| def combinable: Combinable[T] | |
| def combine(other: T) = combinable.combine(self,other) |
OlderNewer