- Дана пара отсортированных списков чисел
lst1
иlst2
. Необходимо вернуть отсортированный список, образованный объединениемlst1
иlst2
. Функциюsort
использовать нельзя. - Реализуйте тип данных, позволяющий задавать команды управления лентой вида "Влево на определённое число шагов", "Вправо на определённое число шагов", "Запись". Реализуйте функцию, которая принимает на вход список команд и начальную позицию и возвращает список позиций, на которых происходила запись.
- Дан список чисел. Необходимо посчитать число чётных и нечётных чисел в этом списке.
- Дан список чисел и функция
f :: Int -> Int -> Int
. Необходимо найти такую пару чисел(a,b)
в списке, чтоf a b
максимально. - Дан список чисел, число
n
и функцияf :: Int -> Int -> Int
. Необходимо найти любую такую пару чисел(a,b)
в списке, чтоf a b
равноn
. - Даны два списка чисел,
a
иb
. Нужно посчитать произведение всех попарных сумм элементов изa
иb
. - Дано число
n
и функцияf :: a -> a
. Необходимо вернуть
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
data BinaryTree = EmptyTree | |
| Leaf Integer | |
| Node Integer BinaryTree BinaryTree | |
hasLeft :: BinaryTree -> Bool | |
hasLeft (EmptyTree) = False | |
hasLeft (Leaf _) = False | |
hasLeft (Node _ EmptyTree _) = False | |
hasLeft (Node _ _ _) = True |
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
[ERROR] java.lang.IllegalStateException: Backend Internal error: Exception during code generation | |
Cause: Back-end (JVM) Internal error: Couldn't inline method call 'forEachOneBit' into | |
@org.junit.Test public final fun smokeTest(): kotlin.Unit defined in ru.spbstu.wheels.BitsTest | |
@Test | |
fun smokeTest() { | |
Bits(0b11001100000).forEachOneBit { bit -> | |
assertEquals(1, bit.popCount) | |
} |
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
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <cassert> | |
#include <memory> | |
#define DECLARE_TUPLE_ACCESSORS_IN_STD(TYPE, SIZE) \ | |
namespace std { \ | |
template<> struct tuple_size<TYPE> { static constexpr const size_t value = SIZE; }; \ | |
template<size_t N> struct tuple_element<N, TYPE> { using type = decltype(std::declval<TYPE>().get<N>()); }; \ |
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
module Parsers where | |
import Text.Parsec hiding(digit) | |
type Parser a = Parsec String () a | |
digit :: Parser Char | |
digit = oneOf $ ['0'..'9'] | |
number :: Parser Integer |
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
const asciiWords = RegExp.prototype.exec.bind(/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g); | |
const hasUnicodeWord = RegExp.prototype.test.bind( | |
/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/ | |
); | |
const unicodeWords = RegExp.prototype.exec.bind(/[a-z0-9]+|[A-Z][a-z0-9]+/g); | |
function* iterateExec(exec: ((string: string) => string[]), string: string): IterableIterator<string> { | |
var res: string[]; |
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
interface Rec<A>: (Rec<A>) -> A | |
inline fun <A> Rec(crossinline body: (Rec<A>) -> A) = object : Rec<A> { | |
override fun invoke(rec: Rec<A>) = body(rec) | |
} | |
fun <T> omega(body: Rec<T>): T = Rec<T> { f -> f(f) } (body) | |
fun <A> y (r: ((A) -> A, A) -> A) = | |
omega(Rec<(A) -> A> { f -> { it -> r({ x -> f(f)(x) }, it) } }) |
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
git init | |
git fetch https://github.com/Jetbrains/kotlin aa83ea22f30d00dc7dbc2f16590933a7ac8965e0 --depth 1 | |
git reset --hard FETCH_HEAD |
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
fun main(args: Array<String>): Unit = runBlocking<Unit> { | |
val warnings = | |
org.jetbrains.kotlin.diagnostics.Errors::class.java.declaredFields | |
.map { it.name to it.get(null) as? DiagnosticFactory<*> } | |
.filter { it.second != null } | |
.filter { it.second?.severity == Severity.WARNING } | |
.map { it.first } | |
.map { """const val $it = "$it" """ } | |
.joinToString("\n") |