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
## mergesort | |
def inversions(arr): | |
(array, inv) = count_inversions(arr) | |
return inv | |
def count_inversions(arr): | |
if len(arr) <= 1: | |
return (arr, 0) | |
mid = len(arr) / 2 | |
left = arr[:mid] |
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
import Control.Monad | |
inversions :: [Int] -> Int | |
inversions = snd . countInversions | |
countInversions :: [Int] -> ([Int], Int) | |
countInversions [] = ([] , 0) | |
countInversions [x] = ([x], 0) | |
countInversions arr = let mid = (length arr) `div` 2 | |
left = take mid arr |
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
54044 | |
14108 | |
79294 | |
29649 | |
25260 | |
60660 | |
2995 | |
53777 | |
49689 | |
9083 |
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
import Control.Monad | |
import Data.Vector hiding (map) | |
import Prelude hiding (head, tail, length, splitAt) | |
import System.IO | |
inversions :: Vector Int -> Int | |
inversions = snd . countInversions | |
countInversions :: Vector Int -> (Vector Int, Int) | |
countInversions xs |
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
module Server where | |
import frege.java.IO hiding (OutputStream) | |
data Executor = native java.util.concurrent.Executor | |
data InetSocketAddress = native java.net.InetSocketAddress where | |
native new :: Int -> STMutable s InetSocketAddress |
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
module io.github.mchav.touchcube.CubeActivity where | |
import froid.javax.microedition.khronos.egl.EGLConfig | |
import froid.javax.microedition.khronos.opengles.GL10 | |
import froid.java.nio.ByteBuffer | |
import froid.java.nio.IntBuffer | |
import froid.app.Activity | |
import froid.content.Context |
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
module io.github.mchav.simplecounter.CounterActivity where | |
import froid.app.Activity | |
import froid.os.Bundle | |
import froid.view.View | |
import froid.widget.Button | |
import froid.widget.TextView | |
native module type Activity where {} |
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
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* | |
-optimizationpasses 5 | |
-allowaccessmodification | |
-dontpreverify | |
-dontusemixedcaseclassnames | |
-dontskipnonpubliclibraryclasses | |
-verbose | |
-keepattributes *Annotation* |
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
project.afterEvaluate { | |
extensions.compileFrege = { | |
description = 'Compile Frege to Java' | |
javaexec { | |
android.dexOptions.setJavaMaxHeapSize("4g") | |
android.defaultConfig.setMultiDexEnabled(true) | |
def libs = project.rootDir.path + "/app/libs".replace('/' as char, File.separatorChar) | |
def froid = new File(libs + "/froid.jar".replace('/' as char, File.separatorChar)) |
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
import Control.Monad | |
import Data.Array | |
-- A class for axis-aligned rectangles. | |
-- The rectangle is defined by the left and right most x | |
-- coordinates. And the left and rightmost y coordinates. | |
type Point = (Int, Int) | |
data Rectangle = Rectangle { |
OlderNewer