at crans.org writes:
Hi -cafe,
I have a question about Codec.Crypto.RSA: how to enforce that
(informally) decrypt . encrypt = id
Consider this code:
That's certainly what I would expect and one of the unit tests that comes
with
http://hackage.haskell.org/packages/archive/Crypto/4.2.2/doc/html
Charles-Pierre Astolfi wrote:
Here's a working example:
import qualified Codec.Crypto.RSA as Crypto
import System.Random (mkStdGen)
import Data.Binary (encode)
import Data.ByteString.Lazy.UTF8 (toString)
n = 1024
(pubKey,privKey,_) = Crypto.generateKeyPair (mkStdGen n) n
encrypt ::
) so I guess I have to stick with Codec.Crypto.RSA.
Any ideas?
--
Cp
On Sat, Nov 20, 2010 at 12:50, Dominic Steinitz domi...@steinitz.org
wrote:
Charles-Pierre Astolfi cpa at crans.org writes:
Hi -cafe,
I have a question about Codec.Crypto.RSA: how to enforce
Thank you for these excellent explanations.
Best regards,
Jerz
--
View this message in context:
http://haskell.1045720.n5.nabble.com/a-simple-question-about-types-tp3269519p3272344.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com
Hi -cafe,
I have a question about Codec.Crypto.RSA: how to enforce that
(informally) decrypt . encrypt = id
Consider this code:
encrypt2 :: String - ByteString
encrypt2 = fst . encrypt (mkStdGen n) pubKey encode
decrypt2 :: ByteString - String
decrypt2 = toString . decrypt privKey
Since
Hello,
Is it possible for a quasi quoter to have access to information about
haskell identifiers declared before the quasi-quotation?
I tried the 'reify' function but without success.
Just as in the following exemple:
a = 6
x = [$expr|a|]
Where the generated haskell code is
a= 6
x = a
On Nov 19, 2010, at 6:00 PM, jean-christophe mincke wrote:
Hello,
Is it possible for a quasi quoter to have access to information about haskell
identifiers declared before the quasi-quotation?
Nope. There are staging restrictions in place, since you can't sanely use
things that haven't
:: Integer - Integer
One more combination, now I write
h x = (2*) x
and check once more
:t h
to get
h :: (Num a) = a - a
So my question is: why (in this second example) Integer is inferred?
What makes a difference?
The monomorphism restriction.
And default. If you load this into ghci
a) = a - a
So my question is: why (in this second example) Integer is inferred?
What makes a difference?
Jerz
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On Nov 17, 2010, at 10:09 AM, Jerzy M wrote:
So my question is: why (in this second example) Integer is inferred?
What makes a difference?
I think there are two things going on. First, the monomorphism
restriction is causing the types to be different. I'm not sure why
Integer
write
h x = (2*) x
and check once more
:t h
to get
h :: (Num a) = a - a
So my question is: why (in this second example) Integer is inferred?
What makes a difference?
The monomorphism restriction.
As specified in section 4.5.5 of the language report
(http://www.haskell.org/onlinereport
Now of course, the followup question is what the heck is a
monomorphism restriction and why would I want it?
Here is a simple example:
expensiveComputation :: Num a = a - a
expensiveComputation x = ... something that takes a long time to compute ...
ghci :t (expensiveComputation 2
On Wednesday 17 November 2010 20:19:17, Ryan Ingram wrote:
Now of course, the followup question is what the heck is a
monomorphism restriction and why would I want it?
Here is a simple example:
snip
But if you give g the more general type signature, the
expensiveComputation has to get run
I trying to learn a bit about data parallel haskell, and started from the
wiki page here: http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell.
Two questions:
The examples express the dot product as:
dotp_double xs ys = sumP [:x *
I trying to learn a bit about data parallel haskell, and started from the
wiki page here:http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell.
Two questions:
The examples express the dot product as:
dotp_double xs ys = sumP [:x *
On Friday 15 October 2010 14:59:18, Warren Harris wrote:
I trying to learn a bit about data parallel haskell, and started from
the wiki page here:
http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell. Two
questions:
The examples express the dot product as:
dotp_double xs ys = sumP
Got it - thanks. Any idea about the run-away process problem? Thanks,
Warren
On Fri, Oct 15, 2010 at 9:32 AM, Daniel Fischer daniel.is.fisc...@web.dewrote:
On Friday 15 October 2010 14:59:18, Warren Harris wrote:
I trying to learn a bit about data parallel haskell, and started from
the
Ben Franksen schrieb:
Neil Mitchell wrote:
This makes me curious. What's the use case where you want to allow the
user to pass arguments on the command line, but you don't want that user
to be able
to use '--help' to find out what arguments may be passed?
I wanted to create a clone of an
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 10/13/10 06:07 , Henning Thielemann wrote:
Ben Franksen schrieb:
I wanted to create a clone of an existing program that had no help option
and instead gave the help output if it saw an invalid option.
I find it very annoying if a program
This makes me curious. What's the use case where you want to allow the user
to pass arguments on the command line, but you don't want that user to
be able
to use '--help' to find out what arguments may be passed?
When you don't want to bother defining the help options/descriptions? :p
Hi,
Am Dienstag, den 12.10.2010, 16:42 +1100 schrieb Ivan Lazar Miljenovic:
On 12 October 2010 16:32, Magnus Therning mag...@therning.org wrote:
This makes me curious. What's the use case where you want to allow the user
to pass arguments on the command line, but you don't want that user
Neil Mitchell wrote:
This makes me curious. What's the use case where you want to allow the
user to pass arguments on the command line, but you don't want that user
to be able
to use '--help' to find out what arguments may be passed?
I wanted to create a clone of an existing program that had
Joachim Breitner wrote:
Am Dienstag, den 12.10.2010, 16:42 +1100 schrieb Ivan Lazar Miljenovic:
On 12 October 2010 16:32, Magnus Therning mag...@therning.org wrote:
This makes me curious. What's the use case where you want to allow the
user to pass arguments on the command line, but you
The point here was not so much removing --help, but rather that I want to
have control over the 'standard' options (help,version,verbosity) in the
same way as for the rest. My program might not have a version, so why
offer --version? Or maybe I want a different name for it because the -V is
Hi Ben,
How can I disable the standard arguments 'help' and 'version'?
In general I suggest you email the author of the cmdargs package
directly, as well as cc'ing the mailing list (otherwise the author
might miss this message, as I did!)
In CmdArgs there is currently no way to suppress either
On 11/10/10 22:04, Neil Mitchell wrote:
Hi Ben,
How can I disable the standard arguments 'help' and 'version'?
In general I suggest you email the author of the cmdargs package
directly, as well as cc'ing the mailing list (otherwise the author
might miss this message, as I did!)
In CmdArgs
On 12 October 2010 16:32, Magnus Therning mag...@therning.org wrote:
This makes me curious. What's the use case where you want to allow the user
to pass arguments on the command line, but you don't want that user to
be able
to use '--help' to find out what arguments may be passed?
When you
On Sep 30, 2010, at 1:39 AM, Patrick Browne wrote:
I think my original question can be rephrased as:
Can type classes preserve satisfaction under the the expansion
sentences
(signature/theory morphisms inducing a model morphism).
According to [1] expansion requires further measures
On Sun, 03 Oct 2010 19:18:08 +0200, Ben Franksen
ben.frank...@online.de wrote:
How can I disable the standard arguments 'help' and 'version'?
If you're not fully committed to the cmdargs package, you might try my
package 'console-program' instead
Arie Peterson wrote:
On Sun, 03 Oct 2010 19:18:08 +0200, Ben Franksen
ben.frank...@online.de wrote:
How can I disable the standard arguments 'help' and 'version'?
If you're not fully committed to the cmdargs package, you might try my
package 'console-program' instead
Does this one give the expected error message for Parsec3.1 -
unfortunately I can't test as I'm still using Parsec 2.1.0.1.
parser = block (many digit ? digit)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Stephen Tetley wrote:
Does this one give the expected error message for Parsec3.1 -
unfortunately I can't test as I'm still using Parsec 2.1.0.1.
parser = block (many digit ? digit)
Unfortunately, no.
Cheers
Ben
___
Haskell-Cafe mailing list
How can I disable the standard arguments 'help' and 'version'?
Cheers
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On Sun, Oct 3, 2010 at 11:55 AM, Ben Franksen ben.frank...@online.de wrote:
Stephen Tetley wrote:
Does this one give the expected error message for Parsec3.1 -
unfortunately I can't test as I'm still using Parsec 2.1.0.1.
parser = block (many digit ? digit)
Unfortunately, no.
Cheers
Ben
Antoine Latter wrote:
On Sun, Oct 3, 2010 at 11:55 AM, Ben Franksen ben.frank...@online.de
wrote:
Stephen Tetley wrote:
Does this one give the expected error message for Parsec3.1 -
unfortunately I can't test as I'm still using Parsec 2.1.0.1.
parser = block (many digit ? digit)
On Wed, Sep 29, 2010 at 1:01 PM, Daniel Fischer
daniel.is.fisc...@web.de wrote:
On Wednesday 29 September 2010 19:10:22, Ben Franksen wrote:
Note the last line mentions only '}'. I would rather like to see
expecting } or digit
since the parser could very well accept another digit
for this behaviour?
(2) Is there another combinator that behaves as I would like?
(3) Otherwise, how do I write one myself?
ask derek.a.elk...@gmail.com (CCed)
Cheers Christian
I just saw that Christian Maeder answered a similar question recently. I
tried his suggestion of using manyTill
Christian Maeder wrote:
Am 29.09.2010 20:01, schrieb Daniel Fischer:
On Wednesday 29 September 2010 19:10:22, Ben Franksen wrote:
Note the last line mentions only '}'. I would rather like to see
expecting } or digit
since the parser could very well accept another digit here.
parsec2
Am 29.09.2010 05:35, schrieb Peter Schmitz:
[...]
Error parsing file: ...\sampleTaggedContent.txt (line 4, column 1):
unexpected end of input
expecting
The input was:
[...]
-- Parsers:
taggedContent = do
optionalWhiteSpace
aTag
many tagOrContent
aTag
many tagOrContent
Am 29.09.2010 09:54, schrieb Christian Maeder:
Am 29.09.2010 05:35, schrieb Peter Schmitz:
[...]
Error parsing file: ...\sampleTaggedContent.txt (line 4, column 1):
unexpected end of input
expecting
The input was:
[...]
-- Parsers:
taggedContent = do
optionalWhiteSpace
aTag
Am 29.09.2010 11:55, schrieb Christian Maeder:
Am 29.09.2010 09:54, schrieb Christian Maeder:
Am 29.09.2010 05:35, schrieb Peter Schmitz:
[...]
Error parsing file: ...\sampleTaggedContent.txt (line 4, column 1):
unexpected end of input
expecting
The input was:
[...]
-- Parsers:
I have a question about Parsec. The following program
import Control.Applicative ((*),(*))
import Text.Parsec
import Text.Parsec.Char
block p = char '{' * p * char '}'
parser = block (many digit)
main = parseTest parser {123a}
gives the output
parse error at (line 1, column 5
?
I just saw that Christian Maeder answered a similar question recently. I
tried his suggestion of using manyTill and bingo:
{-# LANGUAGE NoMonomorphismRestriction #-}
import Control.Applicative ((*),(*))
import Text.Parsec
block p = char '{' * p * char '}'
parser = block (manyTill digit (char
or
accidental.
(1) What is the reason for this behaviour?
(2) Is there another combinator that behaves as I would like?
(3) Otherwise, how do I write one myself?
I just saw that Christian Maeder answered a similar question recently. I
tried his suggestion of using manyTill and bingo
write one myself?
I just saw that Christian Maeder answered a similar question recently. I
tried his suggestion of using manyTill and bingo:
{-# LANGUAGE NoMonomorphismRestriction #-}
import Control.Applicative ((*),(*))
import Text.Parsec
block p = char '{' * p * char '}'
parser = block
Antoine and Christian:
Many thanks for your help on this thread.
(I am still digesting it; much appreciated; will post when I get it working.)
-- Peter
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Hello Cafe,
I have the following type which represents some action using Git
newtype (Monad m) = Git m a = Git { runGit :: ErrorT String (StateT
Environment m) a }
deriving (Monad, MonadState Environment, MonadError String)
and the following typeclass whose purpose is to
Alexander Solla wrote:
Doing similar constructions with type classes is possible. I think you
might have to use witness types (or even a nice functorial wrapper
around your target value in the original algebra, or both) to do
generalizations of type classes. For example:
class Uneditable
Arnaud,
You might also consider writing monad-agnostic code: code that doesn't
know which monad it is executing in.
For example:
class (Monad g) = MonadGit g where
gitOp1 ::
gitOp2 ::
instance MonadGit Git where
gitOp1 = ...
gitOp2 = ...
...
intance MonadGit
Look rather obvious when explained :-) And this is a pattern I have
already used for other code :-(
Thanks a lot Jonathan, that's indeed quite helpful.
Regards
Arnaud
On Tue, Sep 28, 2010 at 3:03 PM, Jonathan Geddes
geddes.jonat...@gmail.com wrote:
Arnaud,
You might also consider writing
I am a new Parsec user, and having some trouble with a relatively
simple parser.
The grammar I want to parse contains tags (not html) marked by
angle brackets (e.g., some tag), with arbitrary text (no angle
brackets allowed) optionally in between tags.
Tags may not nest, but the input must begin
On 09/28/2010 03:03 AM, Patrick Browne wrote:
I had a look at the types of a and a’.
*Main :t a
a :: forall a obj. (Uneditable obj) = a - obj
*Main :t a'
a' :: forall witness a obj. (Refactored obj witness) = Maybe (a - obj)
Could you explain the example a little more.
This is going to
On Tue, Sep 28, 2010 at 10:35 PM, Peter Schmitz ps.hask...@gmail.com wrote:
I am a new Parsec user, and having some trouble with a relatively
simple parser.
The grammar I want to parse contains tags (not html) marked by
angle brackets (e.g., some tag), with arbitrary text (no angle
brackets
Alexander Solla wrote:
On 09/26/2010 01:32 PM, Patrick Browne wrote:
Bigger how? Under logical implication and its computational analogue?
That is to say, do you want the model to be more SPECIFIC, describing a
smaller class of objects more richly (i.e, with more logical
implications to
hold at the programming level.
Well, my question was more along the lines of do you want bigger (more
specific) theories (and so more specific models to interpret them)?
or do you want to generalize from a given theory? To do the latter with
Haskell, you might create a module that allows
On Fri, Sep 24, 2010 at 9:28 PM, Evan Laforge qdun...@gmail.com wrote:
simpleComment = do{ string !--
; manyTill anyChar (try (string --))
}
Note the overlapping parsers anyChar and string !--, and
therefore the use of the try combinator.
First, I would
Stephen,
Thanks much for the pointer to the examples in the sources; found them.
(Its nice to learn from the coding style used by the authors.)
-- Peter
On Sat, Sep 25, 2010 at 12:34 AM, Stephen Tetley
stephen.tet...@gmail.com wrote:
On 25 September 2010 05:30, Evan Laforge qdun...@gmail.com
Hi,
Below is an assumption (which could be wrong) and two questions.
ASSUMPTION 1
Only smaller models can be specified using the sub-class mechanism.
For example if we directly make a subclass A = B then every instance of
B must also be an instance of A (B implies A or B is a subset of A).
Hence,
On 09/26/2010 01:32 PM, Patrick Browne wrote:
Hi,
Below is an assumption (which could be wrong) and two questions.
ASSUMPTION 1
Only smaller models can be specified using the sub-class mechanism.
For example if we directly make a subclass A = B then every instance of
B must also be an
On 25 September 2010 05:30, Evan Laforge qdun...@gmail.com wrote:
I thought the parsec source included some example parsers for simple
languages? In any case, there is lots of material floating around,
[Snip]
The best documentation is Daan Leijen's original manual, plus the
original source
On 9/24/10 5:35 AM, Axel Benz wrote:
Can anybody explain why this happens and how I can compose f and g?
Hint: It works fine if f is defined as an unary function.
As already mentioned: (g . f) x y = (\z- g (f z)) x y = g (f x) y
In order to get it to work you need to say that you want to
Hello,
this is maybe a simple question:
cbinary :: a - b - (a - b - b) - (b - c) - c
-- Version 1 works:
cbinary x y f g = g (f x y)
-- Version 2 should be exactly the same according
-- to my understanding of the . operator definition,
-- but fails with:
-- Occurs check
(g . f) x y = (\z - g (f z)) x y = g (f x) y, and you need g (f x y), which
is definitely not the same thing.
24.09.2010 13:35, Axel Benz пишет:
Hello,
this is maybe a simple question:
cbinary :: a - b - (a - b - b) - (b - c) - c
-- Version 1 works:
cbinary x y f g = g (f x y
I am new to parsec and having difficulty understanding the
explanation of manyTill in
http://legacy.cs.uu.nl/daan/download/parsec/parsec.html.
(I really appreciate having this doc by the way; great reference.)
I.e.:
manyTill :: GenParser tok st a - GenParser tok st end - GenParser tok st [a]
[ sorry, forgot reply to all ]
simpleComment = do{ string !--
; manyTill anyChar (try (string --))
}
Note the overlapping parsers anyChar and string !--, and
therefore the use of the try combinator.
First, I would have expected it to instead say:
Note
Thanks Richard and the others who responded to my query.
I truly appreciate you taking the time and effort to respond to me (and the
community) with your thoughts.
I had been reading about recursion, and was thinking only of that approach
to solve this.
My main reson for looking into Haskell is
Christopher Tauss schrieb:
I am a professional programmer with 11 years experience, yet I just do
not seem to be able to get the hang of even simple things in Haskell. I
am trying to write a function that takes a list and returns the last n
elements.
Looking through the glasses of lazy
2010/9/18 Daniel Fischer daniel.is.fisc...@web.de
n_lastn n = reverse . take n . reverse
Which is the most elegant definition, but it's an O(length list) space
operation (as are all others proposed so far). T
No!. You forget laziness!. it is 0(n) with n= the parameter passed to
Luke Palmer schrieb:
I think this is O(n) time, O(1) space (!).
lastk :: Int - [a] - [a]
lastk k xs = last $ zipWith const (properTails xs) (drop k xs)
where properTails = tail . tails
If (drop k xs) is empty, this yields an error when calling 'last'. This
might be a bug or a feature.
Hi Alberto,
On 20.09.2010, at 10:53, Alberto G. Corona wrote:
2010/9/18 Daniel Fischer daniel.is.fisc...@web.de
n_lastn n = reverse . take n . reverse
Which is the most elegant definition, but it's an O(length list) space
operation (as are all others proposed so far). T
No!. You
On Sep 20, 2010, at 5:10 AM, Jean-Marie Gaillourdet wrote:
Hi Alberto,
On 20.09.2010, at 10:53, Alberto G. Corona wrote:
2010/9/18 Daniel Fischer daniel.is.fisc...@web.de
n_lastn n = reverse . take n . reverse
Which is the most elegant definition, but it's an O(length list) space
Hi James,
On 20.09.2010, at 15:20, James Andrew Cook wrote:
Lazyness helps helps to reduce work if your input list is lazily constructed
and your function forces the returned element. Then you don't have to force
all elements of the list, only the last one. Let's say l = [e_0, ..., e_n].
On Monday 20 September 2010 15:20:53, James Andrew Cook wrote:
On Sep 20, 2010, at 5:10 AM, Jean-Marie Gaillourdet wrote:
Hi Alberto,
On 20.09.2010, at 10:53, Alberto G. Corona wrote:
2010/9/18 Daniel Fischer daniel.is.fisc...@web.de
n_lastn n = reverse . take n . reverse
Have we put off the ultra-newbie by derailing his simple question into a
discussion on subtle issues he shouldn't care about this early on?
On Mon, Sep 20, 2010 at 3:49 PM, Daniel Fischer daniel.is.fisc...@web.dewrote:
On Monday 20 September 2010 15:20:53, James Andrew Cook wrote:
On Sep 20
would ever be needed.
On Sep 20, 2010, at 10:22 AM, Daniel Peebles wrote:
Have we put off the ultra-newbie by derailing his simple question into a
discussion on subtle issues he shouldn't care about this early on?
Probably. It's both a joy and a curse having a community so enthusiastic
On Sep 18, 2010, at 7:51 PM, Christopher Tauss wrote:
Hello Haskell Community -
I am a professional programmer with 11 years experience, yet I just do not
seem to be able to get the hang of even simple things in Haskell. I am
trying to write a function that takes a list and returns the
On Sun, Sep 19, 2010 at 5:01 PM, Henrique Becker
henriquebecke...@gmail.com wrote:
Why not?
import Data.Number.Nat as N
lastN :: Integral b = b - [a] - [a]
lastN n xs = N.drop (N.length xs - n') xs
where n' = N.toNat n
Wow. That is gorgeous! I think it's basically the same idea as
On Mon, Sep 20, 2010 at 5:11 PM, Luke Palmer lrpal...@gmail.com wrote:
On Sun, Sep 19, 2010 at 5:01 PM, Henrique Becker
henriquebecke...@gmail.com wrote:
Why not?
import Data.Number.Nat as N
lastN :: Integral b = b - [a] - [a]
lastN n xs = N.drop (N.length xs - n') xs
where n' =
Thanks, It's my first post.
If you not import Prelude is more clear (N. is horrible):
import Prelude ((-), Integral)
import Data.Number.Nat (drop, length, toNat)
lastN :: Integral b = b - [a] - [a]
lastN n xs = drop (length xs - n') xs
where n' = toNat n
P.S.: You benchmarked? I
I like this one!
Here's a variant using fold:
lastk :: Int - [a] - [a]
lastk k xs = foldl' (const.tail) xs (drop k xs)
or point free:
lastk = ap (foldl' (const. tail)). drop
Hallo Luke Palmer, je schreef op 18-09-10 22:42:
I think this is O(n) time, O(1) space (!).
lastk :: Int - [a] - [a]
Why not?
import Data.Number.Nat as N
lastN :: Integral b = b - [a] - [a]
lastN n xs = N.drop (N.length xs - n') xs
where n' = N.toNat n
Not import Prelude maybe make more clear.
[]'s
Henrique Becker
___
Haskell-Cafe mailing list
Hello Haskell Community -
I am a professional programmer with 11 years experience, yet I just do not
seem to be able to get the hang of even simple things in Haskell. I am
trying to write a function that takes a list and returns the last n
elements.
There may be a function which I can just call
On 18 September 2010 17:51, Christopher Tauss ctau...@gmail.com wrote:
Hello Haskell Community -
I am a professional programmer with 11 years experience, yet I just do not
seem to be able to get the hang of even simple things in Haskell. I am
trying to write a function that takes a list and
Here is a more manual way to do it, hopefully this shows the approach
required. You don't need to store anything, just keep removing the
head of the list until its of the size you want.
n_lastn :: Int - [a] - [a]
n_lastn n xs =
let len = length xs - n
drp = if len 0 then 0 else len
Am 18.09.2010 09:51, schrieb Christopher Tauss:
I am trying to write a function that takes a list and returns the last n
elements.
last_n n = fst . foldr step ([], n)
where
step _ (xs, 0) = (xs, 0)
step x (xs, n) = (x:xs, n-1)
___
On 09/18/2010 02:51 AM, Christopher Tauss wrote:
I am trying to write a function that takes a list and returns the last n
elements.
This may just be for the sake of learning, in which case this is fine,
but usually, needing to do this would be a sign that you are using lists
improperly
Thanks you Ivan and David for clarifying this.
Best Regards,
Chris
On Sat, Sep 18, 2010 at 3:55 AM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
On 18 September 2010 17:51, Christopher Tauss ctau...@gmail.com wrote:
Hello Haskell Community -
I am a professional programmer
On Sat, 2010-09-18 at 03:51 -0400, Christopher Tauss wrote:
Hello Haskell Community -
I am a professional programmer with 11 years experience, yet I just do
not seem to be able to get the hang of even simple things in Haskell.
I am trying to write a function that takes a list and returns
On Saturday 18 September 2010 19:44:38, Jake McArthur wrote:
On 09/18/2010 02:51 AM, Christopher Tauss wrote:
I am trying to write a function that takes a list and returns the last
n elements.
This may just be for the sake of learning, in which case this is fine,
but usually, needing to do
I think this is O(n) time, O(1) space (!).
lastk :: Int - [a] - [a]
lastk k xs = last $ zipWith const (properTails xs) (drop k xs)
where properTails = tail . tails
Luke
On Sat, Sep 18, 2010 at 1:51 PM, Daniel Fischer
daniel.is.fisc...@web.de wrote:
On Saturday 18 September 2010 19:44:38,
On Saturday 18 September 2010 22:42:57, Luke Palmer wrote:
I think this is O(n) time, O(1) space (!).
lastk :: Int - [a] - [a]
lastk k xs = last $ zipWith const (properTails xs) (drop k xs)
where properTails = tail . tails
Luke
No, it's O(k) too. You zip [[x_n, x_{n+1}, ... ], ... ]
On Sep 18, 2010, at 12:51 AM, Christopher Tauss wrote:
I am a professional programmer with 11 years experience, yet I just
do not seem to be able to get the hang of even simple things in
Haskell. I am trying to write a function that takes a list and
returns the last n elements.
Translation: Look at Data.Sequence sometime.
On 9/18/10 11:15 AM, Maciej Piechotka wrote:
On Sat, 2010-09-18 at 03:51 -0400, Christopher Tauss wrote:
Hello Haskell Community -
I am a professional programmer with 11 years experience, yet I just do
not seem to be able to get the hang of even
Translation: Look at Data.Sequence sometime.
On 9/18/10 11:15 AM, Maciej Piechotka wrote:
On Sat, 2010-09-18 at 03:51 -0400, Christopher Tauss wrote:
Hello Haskell Community -
I am a professional programmer with 11 years experience, yet I just do
not seem to be able to get the hang of even
I've been playing around with State Monads. Two I looked at earlier used
*sequence* and *replicate* but when I came to this one I found myself puzzling
over how to structure the problem when there was no predetermined count of how
many times to thread the state.
== Program 1
Antoine,
Thank you very much for your reply. Adding type sigs did help me think
about it. I got it to work.
I replaced:
eol = char '\n'
textLines = endBy eol
with:
textLine :: Parser String
textLine = do
x - many (noneOf \n)
char '\n'
return x
textLines :: Parser [String]
On Wednesday 15 September 2010 23:01:34, Peter Schmitz wrote:
textLine :: Parser String
textLine = do
x - many (noneOf \n)
char '\n'
return x
textLines :: Parser [String]
textLines = many textLine
And it can probably be coded more succinctly that that (suggestions
Daniel,
Thanks much; the more I learn Haskell and Parsec, the more I like them.
-- Peter
On Wed, Sep 15, 2010 at 4:02 PM, Daniel Fischer
daniel.is.fisc...@web.de wrote:
On Wednesday 15 September 2010 23:01:34, Peter Schmitz wrote:
textLine :: Parser String
textLine = do
x - many
Hello Haskellers,
Having been pretty much impressed by Don Stewart's Practical Haskell
(http://donsbot.wordpress.com/2010/08/17/practical-haskell/), I
started to write a Haskell script to run maven jobs (yes, I know...).
In the course of undertaking this fantastic endeavour, I started to
use the
On 14/09/10 07:45, Arnaud Bailly wrote:
What surprised me is that I would expect the behaviour of the two
functions to be different:
- in doRunMvnInIO, I would expect stdout's content to be printed
before stderr, ie. the 2 threads are ordered because I call takeMVar
in between calls to forkIO
601 - 700 of 4551 matches
Mail list logo