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
public class Main { | |
public static void main(String[] args) { | |
// Генерируем случайное число в интервале (0, 10000) | |
int num = (new java.util.Random()).nextInt(10001); | |
System.out.printf("Сгенерировали число: %d\n", num); | |
// Выводим количество цифр в сгенерированном числе | |
System.out.printf("Количество цифр в этом числе: %d\n", countDigits(num)); |
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 com.documentum.com.DfClientX; | |
import com.documentum.fc.client.*; | |
import com.documentum.fc.common.DfException; | |
import com.documentum.fc.common.IDfList; | |
import com.documentum.fc.common.IDfLoginInfo; | |
import com.documentum.operations.*; | |
import java.io.*; | |
import java.util.ArrayList; | |
import java.util.List; |
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
def selectionSort[T <% Ordered[T]](seq: Seq[T]): Seq[T] = { | |
def pickMax(seq: Seq[T]): (T, Seq[T]) = | |
seq.tail.foldRight((seq.head, Seq.empty[T])) { | |
case (next, (max, passed)) => | |
if (next > max) | |
(next, max +: passed) | |
else | |
(max, next +: passed) | |
} |
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
<div id="container"> | |
<h1>Hello Plunker!</h1> | |
<p>Привет, ребята!</p> | |
</div> |
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
//In subdirectory src/Foo | |
package Foo | |
object Bar { | |
val str = "Hello, world!" | |
} |
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
#!/usr/bin/env python | |
# DEPENDENCIES: | |
# - requests | |
# Installation: aptitude install python-requests | |
import requests | |
import sys | |
from time import time, sleep |
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
object Bools extends App { | |
class Bool(negated: () => Bool) { | |
def not = negated() | |
} | |
val True: Bool = new Bool(() => False) | |
val False: Bool = new Bool(() => True) | |
assert(True == True) | |
assert(False == False) |
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
/** | |
* Решает задачу о N ферзях [1] для шахматной доски размером NxN. | |
* | |
* Возвращает множество возможных расстановок ферзей на шахматной доске, | |
* такие, чтобы ни один не находился под боем другого. | |
* | |
* Реализация основана на материале [2] курса | |
* "Functional Programming Principles in Scala" (2016), лекция 6.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
/** | |
* Простейшая реализация FRP в виде сигналов, моделирующих значения, зависимые от времени. | |
* | |
* Из курса "Functional Program Design in Scala" (2016), Lecture 4.3 | |
* https://www.coursera.org/learn/progfun2/lecture/5lWVa/lecture-4-3-a-simple-frp-implementation | |
*/ | |
trait SimpleFRP { | |
class Signal[T](expr: => T) { |
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 java.util.concurrent.{Executor, Executors} | |
import java.util.concurrent.atomic.AtomicReference | |
import scala.annotation.tailrec | |
import scala.util.{Failure, Success, Try} | |
import scala.util.control.NonFatal | |
object Future { | |
def apply[T](expression: => T)(implicit executor: Executor) = new FutureImpl(expression) | |
} |
OlderNewer