View MiniPrelude.hs
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
{-# LANGUAGE TypeOperators #-} | |
{- ver. 2017 -} | |
module MiniPrelude ( | |
module Prelude , | |
module MiniPrelude | |
) where | |
-- import GHC.Types hiding ((:)) | |
-- import qualified GHC.Types as GTypes |
View FLOLAC-22-Tasks.hs
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
-- This exercise covers the first 6 and the 8th chapters of "Learn You a Haskell for Great Good!" | |
-- Chapter 1 - http://learnyouahaskell.com/introduction | |
-- Chapter 2 - http://learnyouahaskell.com/starting-out | |
-- Chapter 3 - http://learnyouahaskell.com/types-and-typeclasses | |
-- Chapter 4 - http://learnyouahaskell.com/syntax-in-functions | |
-- Chapter 5 - http://learnyouahaskell.com/recursion | |
-- Chapter 6 - http://learnyouahaskell.com/higher-order-functions | |
-- Chapter 8 - http://learnyouahaskell.com/making-our-own-types-and-typeclasses |
View DeclareData.agda
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
{-# OPTIONS -v meta:5 #-} | |
--{-# OPTIONS -v tc.data.con:16 #-} | |
--{-# OPTIONS -v tc.unquote.def:11 #-} | |
--{-# OPTIONS -v tc.data.sort:21 #-} | |
--{-# OPTIONS -v tc.data.con.comp:6 #-} | |
--{-# OPTIONS -v tc.conv.term:21 #-} | |
--{-# OPTIONS -v scope.lhs:60 #-} | |
--{-# OPTIONS -v scope.operators:60 #-} | |
open import Reflection |
View configuration.nix
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
# Edit this configuration file to define what should be installed on | |
# your system. Help is available in the configuration.nix(5) man page | |
# and in the NixOS manual (accessible by running ‘nixos-help’). | |
{ config, pkgs, ... }: | |
let | |
all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/4b6aab017cdf96a90641dc287437685675d598da") {}; | |
in | |
{ |
View histogram.hs
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
toRecord :: (Int -> Int) -> Int -> (Int -> Int) | |
toRecord r x y | x == y = (r x) + 1 | |
| otherwise = r y | |
histogram :: [Int] -> String | |
histogram xs = unlines (f record max) ++ "==========\n0123456789\n" | |
where count = foldl toRecord (const 0) xs | |
record = map count [0..9] | |
max = maximum record |
View nub.hs
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 Data.List | |
nub xs = map fst . filter (uncurry notElem) $ zip xs (inits xs) |
View sprout-linked-list.cpp
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> | |
struct Node { | |
int data; | |
Node* next; | |
}; | |
Node* head; | |
void print_list(); | |
void push_front(int data); | |
void pop_front(); |
View sprout-double-linked-list.cpp
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
struct node { | |
int data; | |
node *prev, *next; //分別指向前一格與後一格 | |
}; | |
void insert(node *prev, int data) { | |
node* newNode = new node; | |
newNode->data = data; | |
newNode->prev = prev; | |
newNode->next = prev->next; |
View sprout-lining-problem.cpp
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<cstdio> | |
struct node { | |
int num; | |
node* prev = nullptr; | |
node* next = nullptr; | |
}; | |
void printLine(node* head); |
View splitting vector.cpp
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
int* input = new int[num]; | |
vector<thread> threads; | |
int i; | |
for(i = 0; i+segment_size < num; i += segment_size) | |
threads.push_back(thread(sort_segment, input+i, segment_size)); | |
if(num-i > 0) | |
threads.push_back(thread(sort_segment, input+i, num-i)); |