Skip to content

Instantly share code, notes, and snippets.

View Heimdell's full-sized avatar
🔨
Right tool for the right job

Андреев Кирилл Heimdell

🔨
Right tool for the right job
  • Ульяновск
View GitHub Profile
:- op(500, xfy, $).
:- op(499, xfy, o).
apply(F, X, Result) :-
member(Case, F),
copy_term(Case, X -> Result),
!.
funcall(Expr, F, Xs) :-
---- Minecraft Crash Report ----
// I'm sorry, Dave.
Time: 5/24/15 12:32 PM
Description: Ticking memory connection
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:868)
at java.util.TimSort.mergeAt(TimSort.java:485)
at java.util.TimSort.mergeForceCollapse(TimSort.java:426)
@Heimdell
Heimdell / Filter.java
Last active August 29, 2015 14:22
Is there a way to make things simpler in Java 7 (not involving direct exposure of "for"s)?
package traversal;
import java.util.*;
public class Filter {
public static <A> Iterable<A> array(A[] as, Predicate<A> predicate) {
return Filter.the(new NativeArrayAsIterable<A>(as), predicate);
}
public static <A> Iterable<A> the(Iterable<A> as, Predicate<A> predicate) {
import Color exposing (..)
import Dict exposing (..)
import Graphics.Element exposing (..)
import Graphics.Collage exposing (..)
import Keyboard exposing (..)
import Maybe exposing (..)
import Signal exposing (..)
type alias Game =
{ player : Point
@Heimdell
Heimdell / lc.prolog
Last active August 29, 2015 14:23
Prolog lambda-calculus-to-js translator #2
:- op(1030, xfx, is).
:- op(1045, yfx, @).
:- op(1040, yfx, after).
:- op(1050, xfy, to).
:- op(1175, xfy, in).
compile
--> simplify
, toJS
, !
@Heimdell
Heimdell / list_lol.rb
Last active August 29, 2015 14:24
Не думаю, что программирование на Scheme имеет какой-либо эффект на программиста ;)
def list_induction list, stop, step, ret
return stop.(ret) if list.empty?
x = list.shift
return list_induction list, stop, step, -> (args) {
step.(x, args, ret)
}
end
list_induction [1,2,3,4,5],
import Data.List (foldl')
avg list =
let (count, sum) = foldl' collect (0, 0) list
in fromIntegral sum / count
where
collect (count, sum) item =
count `seq`
import Data.List (sortBy)
import Data.Function (on)
merge :: [(Int, a)] -> [(Int, b)] -> [(Maybe a, Maybe b)]
merge az bz = case (az, bz) of
((i, a) : az', (j, b) : bz') ->
case i `compare` j of
LT -> (Just a, Nothing) : merge az' bz
EQ -> (Just a, Just b) : merge az' bz
@Heimdell
Heimdell / it.hs
Last active August 29, 2015 14:26
SEND + MORE = MONEY
import Data.List (permutations)
import Control.Monad (guard)
main = putStrLn $ head solutions
solutions = do
let range = [0.. 9]
[s,e,n,d,m,o,r,y,_,_] <- permutations range
@Heimdell
Heimdell / ke.hs
Last active September 4, 2015 16:56
--module MyZipper
-- ( File()
-- , Position
-- , up
-- , downAtLeft
-- , downAtRight
-- , left
-- , right
-- , comeIn