Skip to content

Instantly share code, notes, and snippets.

View Happypig375's full-sized avatar
💡
Writing C# and F#

Hadrian Tang Happypig375

💡
Writing C# and F#
View GitHub Profile
@Happypig375
Happypig375 / functions.h
Last active September 17, 2023 19:00
COMP2012H Quan Long solves a bug (Bug is seen from the difference in output from lines 24 and 27 of main.cpp)
/* -------------------------------------------------------------- */
/* This part serves as a pseudo random number generator for auto grade purpose only */
/* You are suggested not to refer to these codes in this assignment. */
/* You are not allowed to use global variables in this course. */
unsigned int next_num = 1; // Here we initiate an unsigned integer to be used in the following functions.
unsigned int custom_rand() // This function is used to return a pseudo random number from 0 to 32767.
{
next_num = next_num * 1103515245 + 2011;
return static_cast<unsigned int>(next_num / 65536) % 32768;
@Happypig375
Happypig375 / privacy policy.txt
Created June 21, 2022 14:52
Privacy Policy for PedoApp
The pedometer app collects step counting data, which will not persist after the app is terminated. No extra personal information is collected.
Contact us at [email protected]
@Happypig375
Happypig375 / TypeSwitch.cs
Last active April 29, 2022 09:12
Type switching in F#
[SharpLab.Runtime.JitGeneric(typeof(int))]
[SharpLab.Runtime.JitGeneric(typeof(long))]
[SharpLab.Runtime.JitGeneric(typeof(byte))]
void f<T>(T x) {
if (typeof(T) == typeof(bool)) System.Console.WriteLine((bool)(object)x);
else if (typeof(T) == typeof(int)) System.Console.WriteLine((int)(object)x);
else if (typeof(T) == typeof(long)) System.Console.WriteLine((long)(object)x);
}
[SharpLab.Runtime.JitGeneric(typeof(int))]
[SharpLab.Runtime.JitGeneric(typeof(long))]
@Happypig375
Happypig375 / Rickroll link Combiner.ipynb
Created March 5, 2022 17:46
Rickroll link Combiner
// Code // Usual function name // "Bird"
let I x = x // id (FSharp.Core) // Identity bird, or the Idiot bird
let K x y = x // konst (FSharpPlus) // the Kestrel
let M x y = x (x y) // twice // the Mockingbird
let T x y = y x // |> (FSharp.Core) // the Thrush
let Q x y z = y (x z) // >> (FSharp.Core) // the Queer bird
let S x y z = x z (y z) // apply (applicative) // the Starling
let rec Y f x = f (Y f) x // fix (FSharpx.Extras) // the Sage bird
// More combinators not mentioned in F# for Fun and Profit
@Happypig375
Happypig375 / University.txt
Created June 29, 2019 07:14
An F# university course?
http://teaching.csse.uwa.edu.au/units/CITS3242/
香港資優教育學苑矢志為學員和職員締造安全、愉快正面、平等機會的學習和工作環境,免他們受到騷擾、欺凌、歧視、誹謗和傷害。 資優學苑的成員須竭力追求個人誠信; 承諾以尊重的態度待人; 尊重他人權利和財產; 為個人和團體行為克盡己任; 立志成為具責任感的公民,建設自由學習社區,並把這些信念推展至社會各個層面。 資優學苑會就成員違反承諾作出回應。在有需要的情況下,會採取適當行動,防止上述情況出現,並會就違紀行為進行處分。
The Hong Kong Academy for Gifted Education is committed to providing a safe, positive and pleasant environment which enable students and staff to learn and work with equal opportunity and are free of harassment, bullying, discrimination, vilification and victimisation. Every member of the Academy should make a commitment to strive for personal integrity; to treat others with dignity and respect; to honour the rights and property of others; to take responsibility for individual and group behaviour; and to act as a responsible citizen in a free learning community and in the larger society. The Academy will respond to reports of violation of such commitment and will take appropriate action to prevent, and if necessary, to discipline behaviour that violates this policy.
@Happypig375
Happypig375 / Must-have F# libraries.md
Last active April 18, 2019 06:40
An excerpt from Get Programming with F#

Must-have F# libraries

As an aside to all the NuGet packages you use today (almost all of which can be used seamlessly with F#), this appendix contains a list of popular libraries and tools unique to the F# ecosystem. It’s by no means an exhaustive list of all libraries out there (new libraries are always cropping up), but there should be enough here to give you a few ideas of how to start using F# in new and interesting ways.

1. Libraries

First, we’ll cover a whole set of F# libraries that we haven’t touched on yet in this book. But don’t forget the ones we’ve already covered, such as Paket, FSharp.Data, and Canopy! Note that many of these libraries are just that: libraries, not frameworks. They can be used interchangeably in a flexible manner, without forcing you down a specific path. They’re nearly all open source and free to use (available on GitHub and NuGet), and most work cross-platform without relying on Visual Studio tooling.

1.1. Build and DevOps

F#’s unique syntax, scripting, and langua

@Happypig375
Happypig375 / 1.txt
Created December 18, 2018 15:59
Areas to explore
創意思維
(Creative Thinking)
溝通和協作
(Communication & Collaboration)
基礎算法
(Basic Algorithms)
解難技巧及編程