News for hackers. Stuff that matters.

ostso

    unset -f command_not_found_handle
Re:Fizzbuzz, Interviews, And Overthinking on Thursday October 04, 2012 @07:10PM (#4614893)
For more on monoids, see Brent Yorgey's paper _Monoids: Theme and Variations (Functional Pearl)_ at <http://www.cis.upenn.edu/~byorgey/pub/monoid-pearl.pdf>; (there's also a video of his talk at the Haskell Symposium at <http://www.youtube.com/watch?v=X-8NCkD2vOw>).
Re:Actually, you don't understand lexical scope on Monday September 17, 2012 @10:11PM (#4535931)
Perhaps mistercow means things like

  def foo():
    x = 5
    def bar():
      print x
    def baz():
      x = 6
      print x
    bar()
    baz()
    print x
Which prints 5, 6, 5. If baz tried to print x before assigning, it would be an UnboundLocalError.
Re:Practical functional programming in JavaScript on Thursday July 05, 2012 @03:53AM (#4202151)
Not really -- "any" and "filter" are total functions, but "first" of an empty list is undefined.

On the other hand, that also applies to foldl1 and {max,min}imum{,By}, so it's probably not the reason.

The reason is probably that in JavaScript you can just say a[0] to get the first element element of a.

Re:Everything You Wanted To Know About Caching on Sunday May 20, 2012 @04:56PM (#4000074)
You should add the word "web" to the title. There are many other kinds of caching.
Re:The Y combinator in Javascript on Monday September 05, 2011 @06:24PM (#2963485)
That's a fixed-point combinator, but it's not actually the Y combinator; in fact, it defeats much of the purpose of Y, since it's defined using explicit recursion, which Y is designed to avoid.

If you just want a clear definition of a fixed-point combinator, you might as well use a non-strict language like Haskell, which doesn't require you to eta-expand g. Here's one recursive definition of fix in Haskell:

    fix f = f (fix f)
This is probably the clearest definition you could ask for of what a fixed-point combinator actually is (other than something like "fix f = f (f (f (f (f ...", which is more difficult to give to a computer).

Here's another one, which closer to what you gave in JavaScript (this is what you'll actually find in the Haskell standard libraries):

    fix f = let x = f x in x
(Of course, due to type-checking, it's non-trivial to define the actual non-recursive Y in Haskell; you usually have to resort to using some type-level recursion. But in an untyped non-strict language you could define it easily enough.)
Re:Scala One Liners on Thursday June 02, 2011 @03:20AM (#2611058)
"bar none" is a little excessive -- Haskell's syntax is probably even cleaner. Compare:

  1. map (*2) [1..10]

  2. sum [1..1000]
     -- sum = foldl (+) 0

  3. any (`isInfixOf` tweet) wordlist

  4. fileText <- readFile "data.txt"
     fileLines <- lines <$> readFile "data.txt"

  5. mapM_ putStrLn . map (\i -> "Happy Birthday " ++ if i == 3 then "dear NAME" else "to You") $ [1..4]

  6. (passed, failed) = partition (>60) [49,58,76,82,88,90]

  7. -- I avoid XML so I don't know what library you'd use here.

  8. minimum [14, 35, -7, 46, 98]
     -- minimum = foldl1 min
Re:The Basic Laws of Human Stupidity on Saturday May 21, 2011 @07:12AM (#2570669)
No, because robbing someone of their incentive to work is a net loss to society, so the bandits would no longer be perfect (unless they in turn gain a corresponding incentive to work, or some other equivalent gain).

There are no perfect bandits, let along a society full of them. Scenarios like "If all members of a society were perfect bandits" are hypothetical and don't really translate to any actual human society that you could imagine. Even so, they're useful for illustrating concepts.

This title is designed to get people to click it (to discover what "The One Group" is), rather than to be informative. Please add e.g. ": Developers" to the end of it, so that people can click on it only if they actually want to read the article.
Re:PG on the cover of Forbes on Tuesday November 23, 2010 @12:08AM (#1932608)
The difference is that the whole point of the Y combinator is that it's a fixed-point combinator that doesn't use explicit recursion. Imagine that you didn't have "var", and couldn't name anything (which is the situation in, say, the lambda calculus). Using the Y combinator you could still define recursive functions.
Re:Ask HN: What do geeks in Palo Alto do on weekend nights? on Monday November 15, 2010 @01:27AM (#1905446)
> The court determined that the discount was intended to encourage women to attend the bar in greater numbers, rather than to discourage attendance by males.

Regardless of whether it should be legal or not, "positive discrimination" is still discrimination.

Re:Ask HN: What is Gravity? on Tuesday August 24, 2010 @04:24PM (#1631021)
Here is Richard Feynman's answer to a similar question (this isn't about gravity but about this type of question): http://www.youtube.com/watch?v=wMFPe-DwULM
Re:Terminal Tips and Tricks For Mac OS X on Tuesday July 06, 2010 @01:01PM (#1491562)
Some methods:

1. Change your layout from "USA" to "USA International (AltGr dead keys)". Then use right-alt+key to make various special characters (you can look at what each character does at "Show Current Layout").

2. Enable the "compose key" -- I use the Menu key for this -- which is described at http://sivers.org/compose-key (it's simple to enable: Keyboard Preferences→Layouts→Options→Compose Key Position). Both of these are customizable, so you can add your own combinations if you want.

There are some other ways:

3. Ctrl-Shift-U in a GTK+ text input to enter a code point, as you said.

4. Alternative input methods that let you type special characters in in various other ways, such as LaTeX names, if you prefer that.

It is somewhat ironic that this article is on www.theonion.com...
That seems like a fairly cliché series of dichotomies. Life isn't black and white; if choices were always this clear-cut then they wouldn't be hard.
Re:Zed Shaw has Left Dropbox on Saturday July 03, 2010 @01:35AM (#1483348)
> Either that, or getting a Ph.D. in Education.

Is this a Heinlein reference?

At any rate it violates Facebook's terms (http://www.facebook.com/terms.php, 4.5): "You will not use Facebook if you are under 13."
Re:Where does a tree get its mass? on Thursday July 01, 2010 @08:17PM (#1479724)
More Feynman on the same topic ("Energy makes it go"): http://physics.gu.se/~f3aamp/teaching/wakalix.html
Re:Ask PG: Vim shortcuts for navigating HN? on Saturday June 26, 2010 @03:34AM (#1463327)
See <http://news.ycombinator.com/item?id=277099>; -- the linked post doesn't seem to work for me, but the first link in the first comment does.
> The singular "they", on the other hand, is artificial, at least among people of my generation -- we already have "one", thank you very much.

Huh? Singular "they" has little to do with "one" -- it's used as an alternative to "he"/"she" when the gender is unknown (like the Finnish "hän", for instance).

It may or may not be artificial, but what would you use instead?