Kotlin prepend element

I think the easiest would be to write: var list = listOf(2,3) println(list) // [2, 3] list = listOf(1) + list println(list) // [1, 2, 3] There is no specific tail implementation, but you can call .drop(1) to get the same. You can make this head\tail more generic by writing these extension properties: val <T> … Read more

What’s the difference between `::` and `+:` for prepending to a list)?

The best way to determine the difference between both methods is to look it the source code. The source of ::: def ::[B >: A] (x: B): List[B] = new scala.collection.immutable.::(x, this) The source of +:: override def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[List[A], B, That]): That = bf match { case _: List.GenericCanBuildFrom[_] … Read more

What does “my other car is a cdr” mean?

In Lisp, a linked list element is called a CONS. It is a data structure with two elements, called the CAR and the CDR for historical reasons. (Some Common Lisp programmers prefer to refer to them using the FIRST and REST functions, while others like CAR and CDR because they fit well with the precomposed … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)