> Does anyone know of a trick to accomplish `typeOf id'?
> Using something else than TypeRep as the representation, of course.
Yes. The analysis of polymorphic types has been used in the inverse
type-checker
http://okmij.org/ftp/Haskell/types.html#de-typechecker
The enclosed code compute
On Thu, Mar 26, 2009 at 2:40 AM, Duncan Coutts
wrote:
> I was not being precise when I said "tests for _|_". As you point out,
> the semantics of imprecise exceptions distinguishes exceptions from
> bottom, however pure code cannot make that distinction and so that's why
> I was lumping them toget
On Wed, 2009-03-25 at 18:14 +0100, Benja Fallenstein wrote:
> On Wed, Mar 25, 2009 at 3:52 AM, Duncan Coutts
> > Of course your tryArith only tests for certain kinds of _|_ value, but
> > in principle the problem is the same.
>
> That's not *quite* how the semantics of Haskell exceptions are
> de
On Wed, 2009-03-25 at 15:19 +0100, Achim Schneider wrote:
> Manlio Perillo wrote:
>
> > Should I fill a feature request ticket, or this is how it is supposed
> > to work?
> >
> I would like to be able to do that, too. I also don't want cabal to
> recompile a thousand modules just for a demo progr
Manlio Perillo wrote:
> Heinrich Apfelmus ha scritto:
>>
>> I think you'd have had a much easier time by starting with a proper book
>> right away, like Richard Bird's "Introduction to Functional Programming
>> in Haskell", accompanied by Real World Haskell.
>
> Unfortunately, one year ago Real W
I'm still learning. :) (And I wrote the first available Haskell compiler.)
-- Lennart
On Tue, Mar 24, 2009 at 4:08 AM, Tom.Amundsen wrote:
>
> How long did it take you to become proficient in Haskell? By that, I mean -
> how long until you were just as comfortable with Haskell as you were wi
Using Data.Typeable.typeOf we can get a representation of the the type
of a monomorphic value, for instance
Prelude Data.Typeable> typeOf not
Bool -> Bool
But if we try using it on a polymorphic value it fails
Prelude Data.Typeable> typeOf id
:1:0:
Ambiguous type variable `a' in the c
Henning Thielemann wrote:
Jonathan Cast wrote:
> Xiao-Yong Jin wrote:
> >
> > Could you elaborate more about why this kind of breakage
> > wouldn't happen if 'try' is used in an IO monad as intended?
>
> It would. But it would happen in IO, which is allowed to be
> non-deterministic. Pure Haske
> Beginner list processing code can and often does go awry when presented with
> infinite lists.
I didn't mean code that a beginner would write, I mean code that would
be easy to understand for a beginner to read -- that is, explicit
pattern matching, explicit recursion, no gratuitous use of stat
wren ng thornton wrote:
> All natural languages are Thinking-complete.
>
No, they aren't. Falsifying the Saphir-Worph thesis, I quite often find
myself incapable of expressing a certain thought, or if I succeed,
come up with two or more versions in multiple different languages that
mean slightly
> From: Tim Bauer
>
> I have a program that is currently blowing out the stack,
> Stack space overflow: current size 8388608 bytes.
> Use `+RTS -Ksize' to increase it.
> I am pretty sure I get to the end of the computation that
> increments various statistic counters (lazily?) and only
> whe
Rohit Agrawalla wrote:
> I am a beginner haskell programmer. I am interested in data
> structures implementation (all from basic ones like stack, queues
> etc. to advance ones like balanced binary trees, graphs etc.) in
> haskell. It would be really helpful if someone can point some good
> refe
Zachary Turner wrote:
On Tue, Mar 24, 2009 at 10:32 PM, wren ng thornton wrote:
Both of these conclusions seem quite natural to me, even from before
learning Haskell. It seems, therefore, that "naturality" is not the proper
metric to discuss. It's oft overlooked, but the fact is that expressivi
On Wed, Mar 25, 2009 at 8:25 AM, Jonathan Cast
wrote:
> On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote:
>> the ordering that the state monad expects
>> (and I can never remember which way around they are in Control.Monad.State).
>
> Really? I found it obvious once I figured out it how simp
On Wed, Mar 25, 2009 at 12:44 PM, Thomas Hartman wrote:
>> Are you saying there's a problem with this implementation? It's the
>
> Yes, there is actually a problem with this implementation.
> However, there is something to be said for code that just looks like a
> duck and quacks like a duck. It'
2009/3/25 Rohit Agrawalla :
I am a beginner haskell programmer. I am interested in data structures
implementation (all from basic ones like stack, queues etc. to advance ones
like balanced binary trees, graphs etc.) in haskell. It would be really
helpful if someone can point some good reference
Dan Weston wrote:
So to be clear with the terminology:
inductive = good consumer?
coinductive = good producer?
So fusion should be possible (automatically? or do I need a GHC rule?) with
inductive . coinductive
Or have I bungled it?
Not quite. Induction means starting from base cases and
I am a beginner haskell programmer. I am interested in data structures
implementation (all from basic ones like stack, queues etc. to advance ones
like balanced binary trees, graphs etc.) in haskell. It would be really
helpful if someone can point some good references for the same.
Regards ,
Roh
On Wed, 2009-03-25 at 22:32 +0100, Henning Thielemann wrote:
> On Wed, 25 Mar 2009, Jonathan Cast wrote:
>
> > On Wed, 2009-03-25 at 07:39 -0400, Xiao-Yong Jin wrote:
> >>
> >> Could you elaborate more about why this kind of breakage
> >> wouldn't happen if 'try' is used in an IO monad as intended
On Wed, 25 Mar 2009, Jonathan Cast wrote:
On Wed, 2009-03-25 at 07:39 -0400, Xiao-Yong Jin wrote:
Could you elaborate more about why this kind of breakage
wouldn't happen if 'try' is used in an IO monad as intended?
It would. But it would happen in IO, which is allowed to be
non-determinis
Tom.Amundsen wrote:
How long did it take you to become proficient in Haskell? By that, I mean -
how long until you were just as comfortable with Haskell as you were with
your strongest language at that time?
I probably shouldn't even answer that. I keep thinking I only just found
out about
Pepe Gallardo wrote:
Hi, I am pleased to announce the first release of WinGhci.
WinGhci is a simple GUI for GHCI on Windows. It is closely based on
WinHugs, and provides similar functionality.
This is now #1 on my list of things that must be tried.
__
Felix Martini wrote:
Hi all,
winio is an I/O library for Windows using Windows API functions and
has I/O completion port support. The main goal of this library is to
support Simon Marlow's new Handle API once he has added that to GHC.
The library also has a compatibility module for socket functi
On Wed, 2009-03-25 at 21:18 +, Andrew Coppin wrote:
> I'M ON WINDOWS! ;-)
We've noticed...
jcc
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Max Bolingbroke wrote:
These two packages allow Haskell programs to produce much richer
console output by allowing colorisation, emboldening and so on.
Both Unix-like (OS X, Linux) and Windows operating systems are
supported (via a pure Haskell ANSI emulation layer for Windows).
Examples, scree
Manlio Perillo wrote:
The main problem, here, is that:
- recursion and pattern matching are explained in every tutorial about
functional programming and Haskell.
This is the reason why I find them more "natural".
- high level, Haskell specific, abstractions, are *not* explained in
normal
s/Pattern matching is awesome language feature. use it!
/Pattern matching is awesome language feature. Don't be ashamed to use it! /
:)
2009/3/25 Thomas Hartman :
> Not only is your "simpler" function easier to read, it is also more correct.
>
> partitionsHubris xs ns = zipWith take ns . init $
Not only is your "simpler" function easier to read, it is also more correct.
partitionsHubris xs ns = zipWith take ns . init $ scanl (flip drop) xs ns
partitionsBeginner :: [Int] -> [a] -> [[a]]
partitionsBeginner [] _ = []
partitionsBeginner _ [] = []
partitionsBeginner (n : ns
bauertim:
> I have a program that is currently blowing out the stack,
>Stack space overflow: current size 8388608 bytes.
>Use `+RTS -Ksize' to increase it.
> I am pretty sure I get to the end of the computation that
> increments various statistic counters (lazily?) and only
> when I go to p
Since this thread is ostensibly about haskell style, it should also be
about haskell style *today*.
As I think Yitz noted earlier, this is a moving target.
Adoption of haskell by the masses -- moving.
Skill of haskell hordes -- moving.
Abstractions available as part of "idiomatic haskell", and co
Oh, and incidentally, if you change to Control.Monad.State.Strict
*Main> testP partitionsTooFrickinClever
testP partitionsTooFrickinClever^J*** Exception: stack overflow
Don't get me wrong -- I have learned a lot from this thread, and I
think it would be really cool if there was a way to do this
On Wed, 2009-03-25 at 12:48 -0700, Dan Weston wrote:
> > However, there is something to be said for code that just looks like a
> > duck and quacks like a duck. It's less likely to surprise you.
> >
> > So... I insist... Easy for a beginner to read == better!
>
> All you have said is that one b
Am Mittwoch 25 März 2009 20:00:40 schrieb Tim Bauer:
> I have a program that is currently blowing out the stack,
> Stack space overflow: current size 8388608 bytes.
> Use `+RTS -Ksize' to increase it.
> I am pretty sure I get to the end of the computation that
> increments various statistic
> However, there is something to be said for code that just looks like a
> duck and quacks like a duck. It's less likely to surprise you.
>
> So... I insist... Easy for a beginner to read == better!
All you have said is that one building a skyscraper will need
scaffolding, blueprints, and a goo
> Are you saying there's a problem with this implementation? It's the
Yes, there is actually a problem with this implementation.
import Data.List
import Control.Monad.State
import Debug.Trace.Helpers
partitions [] xs = []
partitions (n:parts) xs =
let (beg,end) = splitAt n xs
in beg : ( cas
So to be clear with the terminology:
inductive = good consumer?
coinductive = good producer?
So fusion should be possible (automatically? or do I need a GHC rule?) with
inductive . coinductive
Or have I bungled it?
Dan
wren ng thornton wrote:
Thomas Hartman wrote:
sorry, wrong function.
Neat, thanks for that tip Peter. It looks like mkbundl does
everything I do manually, and more. But just for the record, in case
anyone (Scott?) wants to do it the hard way... :)
1. Download the macosx-app shell script from wxhaskell. Make it
executable (i.e. "chmod a+x macosx-app")
2.
Make an AState with two !Int fields and increment those.
On Wed, Mar 25, 2009 at 8:00 PM, Tim Bauer wrote:
> I have a program that is currently blowing out the stack,
> Stack space overflow: current size 8388608 bytes.
> Use `+RTS -Ksize' to increase it.
> I am pretty sure I get to the end of
Cool! Thanks, Don. I enjoyed the "show" :)
Duane Johnson
On Mar 24, 2009, at 2:20 AM, Don Stewart wrote:
Hey guys,
I've been making quick youtube videos of projects to convey what they
do. Here, for example, using Tim Docker's Charts library in ghci:
http://www.youtube.com/watch?v=2Lqzy
Thomas Hartman wrote:
sorry, wrong function.
should be
partitions [] xs = []
partitions (n:parts) xs =
let (beg,end) = splitAt n xs
in beg : ( case end of
[] -> []
xs -> partitions parts xs)
It's not tail recursive, FWIW. The recursive expression has (:) as
I have a program that is currently blowing out the stack,
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize' to increase it.
I am pretty sure I get to the end of the computation that
increments various statistic counters (lazily?) and only
when I go to print them out at the
Quoth Jonathan Cast :
> On Wed, 2009-03-25 at 10:00 -0700, Donn Cave wrote:
>> So I thought it would be interesting to explore statements like "you
>> must not do this", and "pure Haskell is not allowed to be
>> non-deterministic", in terms of practical effects. No one would
>> make a statement
or via Arrow:
swap = snd &&& fst
On Wed, Mar 25, 2009 at 9:16 AM, David Menendez wrote:
> On Wed, Mar 25, 2009 at 11:32 AM, Simon Marlow wrote:
> > Jonathan Cast wrote:
> >>
> >> Define
> >>
> >>swap (a, b) = (b, a)
> >
> > ew, that's far too crude. I think you mean
> >
> > swap = uncurr
Hi
A quick Hoogle for ! : http://haskell.org/hoogle/?hoogle=!
Gives the first answer as: http://www.haskell.org/haskellwiki/Keywords#.21
If that isn't clear, someone should expand on it or give further links
to useful resources.
Thanks
Neil
2009/3/25 Harsh Verma :
> I have seen ! added in fro
I have seen ! added in front of many values, is it related to strict
evaluation? Please elaborate on it.
TIA,
gimli
_
Windows Live Messenger. Multitasking at its finest.
http://www.microsoft.com/india/windows/windowslive/messenger.a
Hi,
I'm interested in 3rd central european functional programming school[1].
Maybe some haskellers attended previous CEFPs and want to share (or
already shared) some experience?
Who also is going to attend or participate in this year's CEFP?
1. http://plcportal.inf.elte.hu/en/tfp_cefp_2009/Pa
On Wed, 2009-03-25 at 10:00 -0700, Donn Cave wrote:
> Quoth Jonathan Cast :
> > On Wed, 2009-03-25 at 09:15 -0700, Donn Cave wrote:
>
> >> OK, these are interesting phenomena. From a practical point of view,
> >> though, I could see someone weighing the potential costs and benefits
> >> of a exce
I discovered Haskell about a year and half ago, along with F#.
Beginning with both languages was relatively easy but I already had
experience of FP in lisp and scheme.
And some years ago I took a course in FP (learning CAML which F# is closely
based on).
My study of haskell went smooth up to the
Hi Duncan and all,
On Wed, Mar 25, 2009 at 3:52 AM, Duncan Coutts
wrote:
> On Mon, 2009-03-23 at 08:11 -0400, Xiao-Yong Jin wrote:
>> > tryArith :: a -> Either ArithException a
>> > tryArith = unsafePerformIO . try . evaluate
>
> You must not do this. It breaks the semantics of the language.
>
>
Simon Marlow wrote:
> Jonathan Cast wrote:
>> Define
>>
>> swap (a, b) = (b, a)
>
> ew, that's far too crude. I think you mean
>
> swap = uncurry $ flip (,)
I think I would prefer something that mirrors flip more closely:
swap :: ((a,b) -> c) -> (b,a) -> c
swap = uncurry . flip .
Quoth Jonathan Cast :
> On Wed, 2009-03-25 at 09:15 -0700, Donn Cave wrote:
>> OK, these are interesting phenomena. From a practical point of view,
>> though, I could see someone weighing the potential costs and benefits
>> of a exception handler outside IO like this, and these effects might
>> n
If you think non-determinstic programs are acceptable, then you can
use unsafePerformIO this way.
But future versions of compilers may make them even more
unpredictable, so beware.
I think that if the exception handler does not look at exactly what
exception was thrown, then the program will just
Dear Luke,
I'm at a loss trying to figure out what is happening here, I'd sincerely
appreciate it if you could find the time to give me more clues on this,
I'm deeply impressed. If I think that what is happening *is* happening
that would mean that this is a way to group in almost constant spac
Learning the syntax, a day or two.
Learning major idioms (many of which are encapsulated in modules),
ongoing (it's been about two years of off and on).
Sadly I can't use it for my $work language. If I could then the
time available for learning haskell and paying the mortgage would
not be disjoin
On Wed, 2009-03-25 at 09:15 -0700, Donn Cave wrote:
> Quoth Lennart Augustsson :
>
> > Some examples of what might happen:
>
> OK, these are interesting phenomena. From a practical point of view,
> though, I could see someone weighing the potential costs and benefits
> of a exception handler out
On Wed, 2009-03-25 at 15:32 +, Simon Marlow wrote:
> Jonathan Cast wrote:
> > On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote:
> >> the ordering that the state monad expects
> >> (and I can never remember which way around they are in
> >> Control.Monad.State).
> >
> > Really? I found
On Wed, Mar 25, 2009 at 11:32 AM, Simon Marlow wrote:
> Jonathan Cast wrote:
>>
>> Define
>>
>> swap (a, b) = (b, a)
>
> ew, that's far too crude. I think you mean
>
> swap = uncurry $ flip (,)
On the theme of using monads where you might not expect,
swap = liftA2 (,) snd fst
--
Dave Mene
Quoth Lennart Augustsson :
> Some examples of what might happen:
OK, these are interesting phenomena. From a practical point of view,
though, I could see someone weighing the potential costs and benefits
of a exception handler outside IO like this, and these effects might
not even carry all that
On Wed, 2009-03-25 at 03:01 +, Robin Green wrote:
> On Wed, 25 Mar 2009 08:25:40 -0700
> Jonathan Cast wrote:
>
> > Define
> >
> > swap (a, b) = (b, a)
>
> By the way, if you want to be "too smart", there's a generalised
> version of swap in Control.Category.Braided in the category-extr
On Wed, 25 Mar 2009 08:25:40 -0700
Jonathan Cast wrote:
> Define
>
> swap (a, b) = (b, a)
By the way, if you want to be "too smart", there's a generalised
version of swap in Control.Category.Braided in the category-extras
package.
That might be a bit overkill though.
--
Robin
2009/3/25 Zachary Turner :
>
> On the other hand, -certain- languages are more expressive than others. As
> an example, I personally find English far more expressive than both
> Vietnamese and Japanese, yet English is far more complicated. Japanese, for
Way off topic, but for what it's worth, yo
Simon Marlow wrote:
Jonathan Cast wrote:
Define
swap (a, b) = (b, a)
ew, that's far too crude. I think you mean
swap = uncurry $ flip (,)
I think I would prefer something that mirrors flip more closely:
swap :: ((a,b) -> c) -> (b,a) -> c
swap = uncurry . flip . curry
- Jak
On Wed, Mar 25, 2009 at 4:09 PM, Simon Marlow wrote:
> But it only works out nicely because the ordering of the components of the
> pair returned by splitAt matches the ordering that the state monad expects
> (and I can never remember which way around they are in Control.Monad.State).
>
Now you
Jonathan Cast wrote:
On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote:
the ordering that the state monad expects
(and I can never remember which way around they are in Control.Monad.State).
Really? I found it obvious once I figured out it how simple it made
(>>=). With the order from Co
On Wed, 2009-03-25 at 15:09 +, Simon Marlow wrote:
> the ordering that the state monad expects
> (and I can never remember which way around they are in Control.Monad.State).
Really? I found it obvious once I figured out it how simple it made
(>>=). With the order from Control.Monad.State (w
On Wed, 2009-03-25 at 07:39 -0400, Xiao-Yong Jin wrote:
> Jonathan Cast writes:
>
> > On Tue, 2009-03-24 at 23:13 -0700, Donn Cave wrote:
> >> Quoth Duncan Coutts :
> >>
> >> > You must not do this. It breaks the semantics of the language.
> >> >
> >> > Other people have given practical reasons
Dan Piponi wrote:
Miguel Mitrofanov wrote:
takeList = evalState . mapM (State . splitAt)
However, ironically, I stopped using them for pretty
much the same reason that Manlio is saying.
Are you saying there's a problem with this implementation? It's the
only one I could just read immediatel
Simon Marlow wrote:
> Obviously I think these tickets are important, since I wrote them :-) In
> terms of priority, I think #1567 is at the top: not having this harms our
> ability to reorganise and abstract things, it puts an arbitrary barrier
> between packages. It's possible my perspective is
Isaac Dupree wrote:
I'm interested in being a GSoC student, and the Haddock-related tickets looked
like a good place to start
http://hackage.haskell.org/trac/summer-of-code/ticket/1567
http://hackage.haskell.org/trac/summer-of-code/ticket/1568
http://hackage.haskell.org/trac/summer-of-code/ticke
Manlio Perillo wrote:
> The main problem, here, is that:
> - recursion and pattern matching are explained in every tutorial about
>functional programming and Haskell.
>
>This is the reason why I find them more "natural".
>
Well, you're going to have a hard time writing a BASIC tutorial
John Lato writes:
>> Yes, I know, it's not really complicate to rewrite the above
>> code. But, what do I really gain from this rewrite?
>
> Apologies if this discussion has moved on, but I wanted to comment on this.
>
Thanks for elaborating it more.
>
> You gain correctness. Any functions th
Manlio Perillo wrote:
> Should I fill a feature request ticket, or this is how it is supposed
> to work?
>
I would like to be able to do that, too. I also don't want cabal to
recompile a thousand modules just for a demo program, and don't want to
see hackage being polluted by thousands of foo-lib
Hi.
This example is taken from the Cabal documentation:
Name:TestPackage
...
Library
Build-Depends: HUnit
Exposed-Modules: A, B, C
Executable program1
Main-Is: Main.hs
Hs-Source-Dirs: prog1
Other-Modules: A, B
Executable program2
Main-Is: Main.hs
Having cross-package links would be pure awesome.
On Wed, Mar 25, 2009 at 10:04 AM, Isaac Dupree <
m...@isaac.cedarswampstudios.org> wrote:
> I'm interested in being a GSoC student, and the Haddock-related tickets
> looked
> like a good place to start
> http://hackage.haskell.org/trac/summer-of-c
On Wed, Mar 25, 2009 at 05:54:17PM +1030, Mark Spezzano wrote:
>
> What, strictly speaking, is the definition of ”tail recursive” as opposed to
> just “recursive”?
A recursive function is tail recursive if the final result of the
recursive call is the final result of the function itself. If the
I'm interested in being a GSoC student, and the Haddock-related tickets looked
like a good place to start
http://hackage.haskell.org/trac/summer-of-code/ticket/1567
http://hackage.haskell.org/trac/summer-of-code/ticket/1568
http://hackage.haskell.org/trac/summer-of-code/ticket/1569
... haddock co
On Tue, Mar 24, 2009 at 10:32 PM, wren ng thornton wrote:
> Both of these conclusions seem quite natural to me, even from before
> learning Haskell. It seems, therefore, that "naturality" is not the proper
> metric to discuss. It's oft overlooked, but the fact is that expressivity
> comes not from
The beauty of functional programming is that there doesn't have
to be a conflict between those who prefer explicit and those
who prefer implicit recursion. Think of them as different views
on the same functions - just as with graphical visualizations,
pick the view best suited to your purpose and
wren ng thornton ha scritto:
Manlio Perillo wrote:
[...]
Following directly from the Rule of Least Power, if you can get away
with foreach then that's what you should use. Why? Because the less
power the construct has, the fewer corner cases and generalizations a
reader of the code needs to co
"Alberto G. Corona " wrote:
> However, reusability of source code and maintainability has never
> been taken seriously by haskell programmers, simply because there are
> no industrial projects in Haskell with dozens of people with
> different skills that come and go.
>
Now that's a claim.
In the
Heinrich Apfelmus ha scritto:
Manlio Perillo wrote:
Conal Elliott ha scritto:
Manlio,
We live in the age of participation -- of co-education. Don't worry
about text-books. Contribute to some wiki pages & blogs today that
share these smart techniques with others.
When I started learning Has
o...@okmij.org ha scritto:
Hello!
The reason is that in a project I need to extract random elements
from a list (and I need to extract a lot of them), and using "normal"
methods [1] seems to be rather inefficient.
Note that I have used an incorrect term, sorry.
What I need, in det
> Jake McArthur writes:
>
>> Xiao-Yong Jin wrote:
>> | The problem is that there will be many functions using such
>> | a function to invert a matrix, making this inversion
>> | function return Either/Maybe or packing it in a monad is
>> | just a big headache.
>>
>> I disagree. If you try to take
Some examples of what might happen:
If you have more than one possible exception in your code, you don't
know which one you will get.
It can vary between compilers, optimization levels, program runs, or
even evaluating the same expression within one program.
If you have code that have both an inf
Jonathan Cast writes:
> On Tue, 2009-03-24 at 23:13 -0700, Donn Cave wrote:
>> Quoth Duncan Coutts :
>>
>> > You must not do this. It breaks the semantics of the language.
>> >
>> > Other people have given practical reasons why you should not but a
>> > theoretical reason is that you've defined
> "Compose two alternative STM actions (GHC only). If the first action
> completes without retrying then it forms the result of the orElse.
> Otherwise, if the first action retries, then the second action is
> tried in its place. If both actions retry then the orElse as a whole
> retries."
>
> What
I'm not 100% clear on the behaviour of the STM function orElse. The
documentation says:
"Compose two alternative STM actions (GHC only). If the first action
completes without retrying then it forms the result of the orElse.
Otherwise, if the first action retries, then the second action is
tried i
Dear Günther,
the map can't be consumed while it is constructed. At any point during
its construction you don't know for any key in the map if it will appear
in the not cosumed rest of the list again. This means you can't process
any entry of the map because it may change later. The only point
2009/3/24 John Van Enk :
> If any one seconds the motion, i'm picking up this part of the thread and
> putting it in the humor section of the haskell wiki.
> /jve
Seconded.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mai
sorry, wrong function.
should be
partitions [] xs = []
partitions (n:parts) xs =
let (beg,end) = splitAt n xs
in beg : ( case end of
[] -> []
xs -> partitions parts xs)
t = partitions [1,2,3] [1..10]
which is not quite as nice, I admit.
2009/3/25 Thomas Hart
> > To make a long story short, here is the library code:
> > elems arr = case bounds arr of
> > (_l, _u) -> [unsafeAt arr i | i <- [0 .. numElements arr - 1]
> >
> > And my version:
> > boundedElems arr = case bounds arr of
> > (_l, _u) -> [unsafeAt arr i | i <- [1737 .. 1752]]
> >
> >
What about
import Data.List
partAt n xs =
let (beg,end) = splitAt n xs
in beg : ( case end of
[] -> []
xs -> partAt n xs)
t = partAt 3 [1..10]
It's tail recursive (I think!) and should be pretty easy to understand
even for a beginner, no?
2009/3/24 Manlio Perillo
2009/3/24 Jonathan Cast :
> On Tue, 2009-03-24 at 22:33 +0300, Eugene Kirpichov wrote:
>> Pretty cool once you know what the function does, but I must admit I
>> wouldn't immediately guess the purpose of the function when written in
>> this way.
>
> I wouldn't immediately guess the purpose of the f
wikipedia is your friend...
http://en.wikipedia.org/wiki/Fold_(higher-order_function)
Tammo
2009/3/25 Mark Spezzano :
> Hi,
>
>
>
> Just looking at the definitions for foldr and foldl I see that foldl is
> (apparently) tail recursive while foldr is not.
>
>
>
> Why?
>
>
>
> Is it because foldl d
Hi,
Just looking at the definitions for foldr and foldl I see that foldl is
(apparently) tail recursive while foldr is not.
Why?
Is it because foldl defers calling itself until last whereas foldr evaluates
itself as it runs?
What, strictly speaking, is the definition of ”tail recurs
Dan Piponi wrote:
>> Miguel Mitrofanov wrote:
>>> takeList = evalState . mapM (State . splitAt)
>
>> However, ironically, I stopped using them for pretty
>> much the same reason that Manlio is saying.
>
> Are you saying there's a problem with this implementation? It's the
> only one I could just
96 matches
Mail list logo