Taking a hand (14 mahjong tiles) and figuring out the number of tiles you have to replace to have a winning hand.
This doesn't take account for the value, but just that a hand is in a winning state.
Tenpai is determined if a hand has a Shanten of 1.
| #! /usr/bin/python2.7 | |
| """ | |
| Requires: | |
| Python Imaging Library http://www.pythonware.com/products/pil/ | |
| Version: 1.1.7 for 2.7 | |
| Information: | |
| Python: 2.7.5 | |
| Version: 1.1.0 | |
| Author: Michael Borden <[email protected]> |
| data Test = Test | NotTest | StillNotTest deriving Show | |
| testFuction a@Test {} = a | |
| testFuction _ = NotTest | |
| {- | |
| Test -> Test | |
| NotTest -> NotTest | |
| StillNotTest -> NotTest | |
| -} |
You can get some interesting information with the use of MultiSets in haskell
This example is finding combinations of sequences with a given hand in mahjong. A more indepth explanation can be found here
runFilter $ MS.fromList
[ Suits Character One, Suits Character One, Suits Character One, Suits Character One
, Suits Character Two
, Suits Character Three| function :: x -> x | |
| function x = x | |
| intFunction :: Integer -> Integer | |
| intFunction x = x | |
| numFunction :: Num x => x -> x | |
| numFunction x = x | |
| addNumFunction :: Num x => x -> x -> x |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Css.Default where | |
| import Clay | |
| import Prelude () | |
| defaultStyleSheet :: Css | |
| defaultStyleSheet = do | |
| body ? do |
| -- | When dealing with multiple sets, you can have different | |
| -- constraints. This can be observed in Mahjong where Suits will have | |
| -- nine different values, but honors will vary. Wind and Dragon for | |
| -- example have four and three values respectfully. They also don't | |
| -- fit in with Bounded because these concepts exist together at the | |
| -- same time and need to be handled differently. In many circumstances | |
| -- you can define `minBoundBy` and `maxBoundBy` as just `minBound` and | |
| -- `maxBound`. | |
| class Bounded b => BoundedBy a b where | |
| minBoundBy :: a -> b |
| .PHONY: MPD TEAMSPEAK clean | |
| LIBMPDCLIENT_INCLUDEDIR = libmpdclient/include | |
| LIBMPDCLIENT_HEADERDIR = $(LIBMPDCLIENT_INCLUDEDIR)/mpd | |
| LIBMPDCLIENT_HEADERS := client.h async.h | |
| LIBMPDCLIENT_OUTPUTDIR = src/mpd | |
| TS3SDK_INCLUDEDIR = ts3_sdk/include | |
| TS3SDK_HEADERDIR = $(TS3SDK_INCLUDEDIR)/teamspeak | |
| TS3SDK_HEADERS := clientlib.h |
I tend to focus on core concepts quite a bit more than actual examples, so that the fundamental understanding of what the examples are trying to teach me is building on skills I already have just haven't figured out how to use yet.
tl;dr Your mileage may vary. I learn kind of counterintuitively for others.
Since this seemed to be popular, I decided to make a repository for content about haskell topics that you can find here new materials for lens will be put here
Some basic properties of Tiles
-- | Basic functions of a Tile. Minimum completion is `honor` and `terminal`.
class Tileable a where
suit :: a -> Bool