Skip to content

Instantly share code, notes, and snippets.

View tmountain's full-sized avatar

Travis Whitton tmountain

  • Gainesville, FL
View GitHub Profile
module Shape where
import Data.List (nub)
data Circle = Circle { radius :: Float }
data Triangle = Triangle { a :: Float, b :: Float, c :: Float }
class Dimensions shape where
name :: shape -> String
@tmountain
tmountain / chapter4.purs
Created October 24, 2018 12:41
Purescript by Example Solutions (Chapter 4)
module Even where
import Prelude
import Data.Foldable (product)
import Data.Array (concatMap, null, sort, filter, length, (..))
import Data.Array.Partial (head, tail)
import Partial.Unsafe (unsafePartial)
import Control.MonadZero (guard)
@tmountain
tmountain / folds.hs
Created October 24, 2018 12:39
Lazy vs Non-Lazy Folds
-- lazy vs non-lazy folds
-- works on infinite lists
take 5 $ foldr (:) [] [1..]
-- infinite loop
cons' = flip (:) -- acc is first arg to foldl
take 5 $ foldl cons' [] [1..]
Optimization terminated successfully.
Current function value: 0.375376
Iterations: 6
Function evaluations: 6339
Logit Regression Results
==============================================================================
Dep. Variable: agency No. Observations: 31414
Model: Logit Df Residuals: 31315
Method: MLE Df Model: 98
Date: Thu, 19 Apr 2018 Pseudo R-squ.: 0.4584
Optimization terminated successfully.
Current function value: 0.272877
Iterations: 8
Function evaluations: 8498
Logit Regression Results
==============================================================================
Dep. Variable: agency No. Observations: 31414
Model: Logit Df Residuals: 31313
Method: MLE Df Model: 100
Date: Thu, 19 Apr 2018 Pseudo R-squ.: 0.6063
/usr/local/lib/python2.7/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead.
from pandas.core import datetools
/usr/local/lib/python2.7/site-packages/statsmodels/discrete/discrete_model.py:1214: RuntimeWarning: overflow encountered in exp
return 1/(1+np.exp(-X))
/usr/local/lib/python2.7/site-packages/statsmodels/discrete/discrete_model.py:1264: RuntimeWarning: divide by zero encountered in log
return np.sum(np.log(self.cdf(q*np.dot(X,params))))
Warning: Maximum number of iterations has been exceeded.
Current function value: inf
Iterations: 35
Traceback (most recent call last):
module Main where
import Set
import Text.Pretty.Simple (pPrint)
c1 = Card { shape = Pill, color = Red, shade = Clear, count = One }
c2 = Card { shape = Squiggle, color = Purple, shade = Clear, count = Two }
c3 = Card { shape = Diamond, color = Green, shade = Clear, count = Three }
c4 = Card { shape = Squiggle, color = Purple, shade = Solid, count = Two }
c5 = Card { shape = Diamond, color = Green, shade = Solid, count = One }
module Set
( findSets
, Shape (..)
, Color (..)
, Shade (..)
, Card (..)
, Count (..)
) where
import Data.List (nub, sort, tails)
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
module Main where
import Data.Char (isSpace)
import qualified Data.List as D
import qualified Data.List.Split as S
import qualified Data.Map.Strict as M
import Data.Maybe (fromMaybe)
import qualified Text.Read as TR
data Score = Score