vararg parameter in a Kotlin lambda

I’m afraid this is not possible. The following demonstrates the type of a function with vararg. A vararg parameter is represented by an Array: fun withVarargs(vararg x: String) = Unit val f: KFunction1<Array<out String>, Unit> = ::withVarargs This behavior is also suggested in the docs: Inside a function a vararg-parameter of type T is visible … Read more

Generate a list with lambdas in kotlin

It’s way better to use kotlin.collections function to do this: List(100) { Random.nextInt() } According to Collections.kt inline fun <T> List(size: Int, init: (index: Int) -> T): List<T> = MutableList(size, init) It’s also possible to generate using range like in your case: (1..100).map { Random.nextInt() } The reason you can’t use forEach is that it … Read more

What’s the point of lambda in scheme?

A let is a lambda. E.g. (let ((x 1)) body) can be translated into ((lambda (x) body) 1) Furthermore, in Scheme all control and environment structures can be represented by lambda expressions and applications of lambdas. So, lambda is strictly more powerful than let and forms the basis of many of the interesting constructs found … Read more

apollo-client does not work with CORS

To workaround the CORS issue with Apollo you have to pass the no-cors option to the underlying fetch. import ApolloClient from “apollo-boost”; const client = new ApolloClient({ uri: “your client uri goes here”, fetchOptions: { mode: ‘no-cors’, }, }); This is not a specific Apollo problem, rather a configuration that is meant to be tackled … Read more

Do Java8 lambdas maintain a reference to their enclosing instance like anonymous classes?

Lambda expressions and method references capture a reference to this only if required, i.e. when this is referenced directly or an instance (non-static) member is accessed. Of course, if your lambda expression captures the value of a local variable and that value contains a reference to this it implies referencing this as well…

TypeScript and Knockout binding to ‘this’ issue – lambda function needed?

You can get correct closure for ‘this’ by declaring method body inside class constructor class VM { public deleteItem: (emailToDelete: string) => void; constructor() { this.deleteItem = (emailToDelete: string) => { // ‘this’ will be pointing to ‘this’ from constructor // no matter from where this method will be called this.emails.remove(emailToDelete); } } } UPDATE: … Read more

Is it possible to build a comparatively fast untyped lambda calculus machine?

First, it is possible to compile the lambda calculus efficiently to machine code even on existing architectures. After all, scheme is the lambda calculus plus a bit extra, and it can be compiled efficiently. However, scheme & co are the lambda calculus under strict evaluation. It is also possible to compile the lambda calculus under … Read more

tech