[Haskell-cafe] message passing style like in Haskell?

jinjing nfjinjing at gmail.com
Sun Jun 22 00:19:30 EDT 2008


After some fiddling with this style, here is what I came up with
for the 8 queens problem in the 99 problem set. It's quite entertaining ...
( note: it's brute force and requires a combination library )

queens2 n = n.permutations.filter all_satisfied where
  all_satisfied queens = queens.diff_col && queens.diff_diag
  diff_col queens = queens.unique.is queens
  diff_diag queens =
    n .combinations 2
      .map (map (subtract 1))
      .map (id &&& flip cherry_pick queens)
      .any same_dist.not where
        same_dist (row_pair, col_pair) =
          row_pair.foldl1 (-).abs == col_pair.foldl1 (-).abs

  -- generic helper
  cherry_pick ids xs = ids.map (xs !!)
  is a b = a == b
  unique xs = nub xs

Guess this can conclude this experiment :)

jinjing

On Sun, Jun 22, 2008 at 1:10 AM, Ian Lynagh <igloo at earth.li> wrote:
> On Fri, Jun 20, 2008 at 07:57:58AM +0200, Ketil Malde wrote:
>> "Albert Y. C. Lai" <trebla at vex.net> writes:
>>
>> >> While we are kind of on this topic, what makes the characters ħ þ
>> >> prefix operator by default, while º and most other odd ones infix?
>>
>> > alphanumeric vs non-alphanumeric
>>
>> Testing this, I find that isAlpha is True also for 'º', but as the OP
>> claims, Haskell will use it as a(n infix) symbol.
>
> This is a bug in GHC. The characters <= '\255' were done specially, but
> incorrectly for many of those >= '\128'. I'll fix it, probably by just
> removing the specialisation for them.
>
>
> Thanks
> Ian
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list