// Тип функции A -> B в Scala
trait Function[A, B] {
def apply(p: A): B
}
// Функциональное значение в Scala
This file contains 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
// Bootstrap 5 tabs Scala.js + Outwatch wrapper | |
final class Tab( | |
tabId: String, | |
selected: Boolean, | |
label: String, | |
content: VDomModifier, | |
) { | |
def navLi: HtmlVNode = |
This file contains 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
import outwatch.helpers.AttributeBuilder | |
import outwatch.{Attr, HtmlVNode, VDomModifier} | |
import scala.language.implicitConversions | |
object TestComponent extends TestViews(outwatch.dsl) { | |
type TModifier = VDomModifier | |
type TRes = VDomModifier | |
type AtPr = Attr |
This file contains 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
// "фиксированная" структура | |
sealed trait BinTree | |
final case class BinNode(t1: BinTree, t2: BinTree) extends BinTree | |
final case class Leaf(v: Int) extends BinTree | |
// в фиксированном варианте возможно только создание простых деревьев, | |
// их структура заранее зафиксирована в определениях BinNode и Leaf | |
BinNode(Leaf(1),BinNode(Leaf(2),Leaf(3))) | |
// к примеру, невозможно создать дерево с необязательными элементами | |
// оно не скомпилируется |
This file contains 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 syntax | |
import cats.data.NonEmptyList | |
import cats.syntax.reducible._ | |
package object catssyntax { | |
object InitLastNel { | |
def unapply[T](nel: NonEmptyList[T]): Option[(List[T], T)] = | |
(nel.init, nel.last).some |
This file contains 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
// based on https://michid.wordpress.com/2010/01/29/scala-type-level-encoding-of-the-ski-calculus/ | |
trait Term { | |
type ap[x <: Term] <: Term | |
type eval <: Term | |
} | |
// The S combinator | |
trait S extends Term { | |
type ap[x <: Term] = S1[x] |
This file contains 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
-- since MSSQL 2008 use | |
-- ALTER USER OrphanUser WITH LOGIN = correctedLoginName; | |
DECLARE @uname varchar(30) | |
DECLARE curs1 CURSOR FOR | |
SELECT name | |
FROM sysusers | |
WHERE name <> 'dbo' AND issqluser = 1 AND hasdbaccess = 1 | |
ORDER BY name | |
OPEN curs1 |
This file contains 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
sealed trait Term | |
case class Var(name: String) extends Term | |
case class Lambda(param: Var, body: Term) extends Term | |
case class App(term1: Term, term2: Term) extends Term | |
object LambdaReduce { | |
def substitute(term: Term, v: Var, body: Term): Term = body match { | |
case Var(name) => ??? |
This file contains 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
Check and. | |
Check or. | |
Check True. | |
Check False. | |
Print True. | |
Print False. | |
Variable A: Prop. |
This file contains 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
Definition compose {A: Type} (f g: A -> A) (x: A) := f (g x). | |
Lemma comp_eq: forall (A: Type) (f g: A -> A) (x: A), compose f g x = f (g x). | |
Proof. | |
intros. | |
unfold compose. | |
exact eq_refl. | |
Qed. |
NewerOlder