// Тип функции A -> B в Scala
trait Function[A, B] {
def apply(p: A): B
}
// Функциональное значение в Scala
This file contains hidden or 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
$("#account-selector input").attr('checked', false); |
This file contains hidden or 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
\ProvidesPackage{questiontask} | |
\RequirePackage{exsheets} | |
\newcounter{taskvariant} | |
% Переопределение \task необходимо для работы \questiontask | |
% | |
% ВНИМАНИЕ: | |
% Обновленная версия \task требует, чтобы весь текст примера был заключен в |
This file contains hidden or 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
/*** | |
scalaVersion := "2.12.4" | |
*/ | |
import scala.language.higherKinds | |
/** | |
* Checking boolean function properties via type-level logic in Scala | |
*/ |
This file contains hidden or 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. |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |