ergoplatform / sigmastate-interpreter

ErgoScript compiler and ErgoTree Interpreter implementation for Ergo blockchain
MIT License
63 stars 41 forks source link

[6.0] Serialize SFunc in TypeSerializer #1020

Closed kushti closed 2 months ago

kushti commented 4 months ago

This PR is adding higher-order lambdas support in serialization, thus making them useful.

Example:

{
   val c = Coll(Coll(1))
   def fn(xs: Coll[Int]) = {
     val inc = { (x: Int) => x + 1 }
     def apply(in: (Int => Int, Int)) = in._1(in._2)
     val ys = xs.map { (x: Int) => apply((inc, x)) }
     ys.size == xs.size && ys != xs
   }
   c.exists(fn)
 }

Close #847