Reference: http://fideloper.com/mac-vim-tmux
Don't forget to open a file via vim and installing bundles via :BundleInstall
| import java.io.*; | |
| import java.util.*; | |
| /* | |
| * To execute Java, please define "static void main" on a class | |
| * named Solution. | |
| * | |
| * If you need more classes, simply define them inline. | |
| */ |
| All exercises are attempted on https://coderpad.io |
| // Dependency: elastic4s | |
| import java.util.Calendar | |
| import com.sksamuel.elastic4s.ElasticDsl._ | |
| import com.sksamuel.elastic4s.source.StringDocumentSource | |
| import com.sksamuel.elastic4s.{ElasticClient, ElasticsearchClientUri} | |
| import org.elasticsearch.action.index.IndexResponse | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| import scala.concurrent.Future |
| GET _search | |
| { | |
| "query": { | |
| "match_all": {} | |
| } | |
| } | |
| PUT /megacorp/employee/1 | |
| { | |
| "first_name": "John", |
Reference: http://fideloper.com/mac-vim-tmux
Don't forget to open a file via vim and installing bundles via :BundleInstall
This gist will contain all the exercises from the book
| package com.learner.s99 | |
| /** | |
| * P06 (*) Find out whether a list is a palindrome. | |
| * Example: | |
| * scala> isPalindrome(List(1, 2, 3, 2, 1)) | |
| * res0: Boolean = true | |
| */ | |
| object P06 { | |
| def isPalindrome[T](l:List[T]):Boolean = l == l.reverse |
| package com.learner.s99 | |
| /** | |
| * P05 (*) Reverse a list. | |
| * Example: | |
| * scala> reverse(List(1, 1, 2, 3, 5, 8)) | |
| * res0: List[Int] = List(8, 5, 3, 2, 1, 1) | |
| */ | |
| object P05 { | |
| def reverse[T](l:List[T]): Option[List[T]] = reverse(l, Nil) |
| package com.learner.s99 | |
| /** | |
| * (*) Find the number of elements of a list. | |
| * Example: | |
| * scala> length(List(1, 1, 2, 3, 5, 8)) | |
| * res0: Int = 6 | |
| */ | |
| object P04 { |
| package com.learner.s99 | |
| object P03 { | |
| def nth(n: Int, l: List[Any]): Any = { | |
| require(n >= 0, "n must be greater than or equal to zero") | |
| l match { | |
| case List() => None | |
| case head :: tail if n == 0 => head | |
| case head :: tail if n > 0 => nth(n - 1, tail) | |
| } |