Skip to content

Instantly share code, notes, and snippets.

$("#account-selector input").attr('checked', false);
\ProvidesPackage{questiontask}
\RequirePackage{exsheets}
\newcounter{taskvariant}
% Переопределение \task необходимо для работы \questiontask
%
% ВНИМАНИЕ:
% Обновленная версия \task требует, чтобы весь текст примера был заключен в
@psttf
psttf / post-lattice.scala
Last active January 9, 2018 19:50
Proving boolean function properties via type-level logic in Scala
/***
scalaVersion := "2.12.4"
*/
import scala.language.higherKinds
/**
* Checking boolean function properties via type-level logic in Scala
*/
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.
Check and.
Check or.
Check True.
Check False.
Print True.
Print False.
Variable A: Prop.
@psttf
psttf / reduction.scala
Created April 19, 2019 08:41
Lambda reduction template in Scala
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) => ???
-- 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

Анонимные функции в ООП

// Тип функции A -> B в Scala
trait Function[A, B] {
  def apply(p: A): B
}

// Функциональное значение в Scala
// 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]
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