Skip to content

Instantly share code, notes, and snippets.

@paulp
paulp / gist:9081797
Created February 18, 2014 22:29
Classic.
scala> val buf = ListBuffer(1)
buf: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1)
scala> val xs = buf.toIterable match { case xs: List[Int] => xs }
xs: List[Int] = List(1)
scala> buf ++= 1 to 100
res11: buf.type = ListBuffer(1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100)
scala> xs

Hi, looking for scalac flags?

This gist has been upgraded to a blog post here.

@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
anonymous
anonymous / gist:5375768
Created April 12, 2013 22:39
00:17:34 <retronym> trepidacious_: comonad/costate isn't really neccessary for lenses. try this presentation: http://www.youtube.com/watch?v=efv0SQNde5Q
00:18:03 ? nomadmonad and milessabin quit
00:18:07 <edwardk> hey that looks familiar
00:18:38 ? jesnor (HydraIRC@c-c2c1e455.016-439-6c6b701.cust.bredbandsbolaget.se) quit: Ping timeout: 240 seconds
00:20:52 <gseitz> shouldn't costate just be an implementation detail
00:20:53 <gseitz> ?
00:21:04 ? pantsman and j0ran quit
00:21:24 <larsrh> edwardk: are you aware of an introductory paper about comonads?
00:21:43 <edwardk> not really. i gave a talk on them at the first boston haskell i should have some slides handy
00:21:46 ? vsayer (~vsayer@c-98-207-60-159.hsd1.ca.comcast.net) quit: Ping timeout: 244 seconds
@quchen
quchen / trolling_haskell
Last active February 24, 2024 01:30
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
(ns net.cgrand.decay
"Exponentially decaying lists. See http://awelonblue.wordpress.com/2013/01/24/exponential-decay-of-history-improved/
for background and http://clj-me.cgrand.net/2013/02/12/decaying-lists-log-scale-for-lists/ for documentation")
;; PRNG, formulas straight from java.util.Random javadoc
(defn- seed ^long [^long n]
(bit-and (unchecked-multiply n 0x5DEECE66D)
(unchecked-dec (bit-shift-left 1 48))))
(defn- next-seed ^long [^long seed]
@patriknw
patriknw / PeekMailbox.scala
Created November 21, 2012 14:20
PeekMailbox example
package example
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedQueue
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
import akka.actor.Actor
import akka.actor.ActorContext
import akka.actor.ActorRef
import akka.actor.ActorSystem
@seanparsons
seanparsons / gist:3928225
Created October 21, 2012 19:46
Expanded inventory example using Semigroups.
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
scala> :paste
// Entering paste mode (ctrl-D to finish)
sealed abstract class Inventory
@harshithjvmi
harshithjvmi / github-code-view-expander.js
Created October 17, 2012 06:55
Github code view expander
$("#js-repo-pjax-container, .frames > .frame-center").width($(document.body).width()-20);
@larsrh
larsrh / nameplicitly.scala
Created July 3, 2012 12:29
Attempting a by-name implicitly
import language.experimental.macros
import scala.reflect.makro.Context
object Name {
def nameplicitly[T](implicit t0: T): Name[T] = macro nameplicitly_impl[T]
def nameplicitly_impl[T : c.TypeTag](c: Context)(t0: c.Expr[T]): c.Expr[Name[T]] =
c.reify(new Name[T] { def t = t0.splice })