Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Why is it so slow to solve "10^(10^10)"? (KC)
2. Re: Why is it so slow to solve "10^(10^10)"? (Bob Ippolito)
3. Re: Why is it so slow to solve "10^(10^10)"? (yi lu)
4. Re: Why is it so slow to solve "10^(10^10)"? (Graham Gill)
5. HXT followingSiblingAxis && transform on this and the thing
before (Rene@gmail)
----------------------------------------------------------------------
Message: 1
Date: Sat, 21 Sep 2013 16:11:37 -0700
From: KC <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why is it so slow to solve
"10^(10^10)"?
Message-ID:
<CAMLKXy=9NP-a=asZeeHLOkVwCr3CwDrF0Et=m8-pkbp0_yk...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Have you compared the solution to other languages?
If you are only solving 10^(10^10) why not construct a string with "1"
followed by a 100 zeroes?
In other words, what is this being used for?
On Sat, Sep 21, 2013 at 3:32 PM, yi lu <[email protected]>wrote:
> Why is it so slow to solve "10^(10^10)" in Haskell?
>
> Yi
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
--
--
Regards,
KC
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130921/fbaaf49a/attachment-0001.html>
------------------------------
Message: 2
Date: Sat, 21 Sep 2013 16:11:39 -0700
From: Bob Ippolito <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why is it so slow to solve
"10^(10^10)"?
Message-ID:
<CACwMPm9UeJ8zM+S=zo9yeju_w_cy6egrzd9btucvg5vhw+g...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Why wouldn't it be slow? Integers in Haskell are implemented with GMP, and
the representation is simply a sign, a magnitude (number of bits) and then
all of the bits. http://gmplib.org/manual/Integer-Internals.html
10^(10^10) is a very large number. With the representation that GMP uses,
it will take at least 3.86 GB of RAM to represent the bits required by the
result! Of course it takes ages to work with numbers of that magnitude.
h> ((10^10) * logBase 256 10) * (2**(-30))
3.8672332825224878
It is possible to encode values like this, but there's nothing that ships
with Haskell Platform that'll do it efficiently. You might look at the
numbers package though.
h> import Data.Number.BigFloat
h> ((10 :: BigFloat Eps1)^10)^10
1.e100
Note that the above example is trivial, only one digit of precision, but
that's all that's needed to represent this result since BigFloat is base 10.
-bob
On Sat, Sep 21, 2013 at 3:32 PM, yi lu <[email protected]>wrote:
> Why is it so slow to solve "10^(10^10)" in Haskell?
>
> Yi
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130921/514a27f9/attachment-0001.html>
------------------------------
Message: 3
Date: Sun, 22 Sep 2013 10:02:38 +0800
From: yi lu <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why is it so slow to solve
"10^(10^10)"?
Message-ID:
<cakcmqqx_9no8gkfelyxfxvqneudnqurav8wgn2q7u3l2ch2...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I am checking whether a number equals 10^(10^10).
Yi
On Sun, Sep 22, 2013 at 7:11 AM, KC <[email protected]> wrote:
> Have you compared the solution to other languages?
>
> If you are only solving 10^(10^10) why not construct a string with "1"
> followed by a 100 zeroes?
>
> In other words, what is this being used for?
>
>
>
> On Sat, Sep 21, 2013 at 3:32 PM, yi lu <[email protected]>wrote:
>
>> Why is it so slow to solve "10^(10^10)" in Haskell?
>>
>> Yi
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
>
> --
> --
> Regards,
> KC
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130922/79331628/attachment-0001.html>
------------------------------
Message: 4
Date: Sun, 22 Sep 2013 00:50:18 -0400
From: Graham Gill <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why is it so slow to solve
"10^(10^10)"?
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
10^(10^10) is a 1 followed by ten billion zeros. Naively evaluating that
to an integer is going to cause time and memory problems in any software
that supports arbitrary size integers - as Bob Ippolito said, it's going
to take about 3.86gb just to store such a number in binary. Even math
software (Maple) rejects an attempt to evaluate it directly - sensibly,
the "arbitrary size" integers in Maple do have a maximum.
> h> import Data.Number.BigFloat
> h> ((10 :: BigFloat Eps1)^10)^10
> 1.e100
and
> If you are only solving 10^(10^10) why not construct a string with "1"
> followed by a 100 zeroes?
10^(10^10) isn't the same as (10^10)^10, which is a 1 followed by 100
zeros, easy to evaluate to an integer in Haskell.
Evaluating (10 :: BigFloat Eps1)^(10^10) runs into the same problems as
10^(10^10):
Prelude> 10^(10^10)
<interactive>: out of memory
[restart]
Prelude> 10.0^(10^10)
Infinity
Prelude> 10.0**(10.0^10)
Infinity
Prelude> import Data.Number.BigFloat
Prelude Data.Number.BigFloat> (10 :: BigFloat Eps1)^(10^10)
<interactive>: out of memory
Maple> 10.0^(10^10);
Maple> 10^(10^10);
Error, operation failed. Integer exponent too large.
Graham
On 21/09/2013 10:02 PM, yi lu wrote:
> I am checking whether a number equals 10^(10^10).
>
> Yi
>
>
> On Sun, Sep 22, 2013 at 7:11 AM, KC <[email protected]
> <mailto:[email protected]>> wrote:
>
> Have you compared the solution to other languages?
>
> If you are only solving 10^(10^10) why not construct a string with
> "1" followed by a 100 zeroes?
>
> In other words, what is this being used for?
>
>
>
> On Sat, Sep 21, 2013 at 3:32 PM, yi lu
> <[email protected]
> <mailto:[email protected]>> wrote:
>
> Why is it so slow to solve "10^(10^10)" in Haskell?
>
> Yi
>
> _______________________________________________
> Beginners mailing list
> [email protected] <mailto:[email protected]>
> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
>
> --
> --
> Regards,
> KC
>
> _______________________________________________
> Beginners mailing list
> [email protected] <mailto:[email protected]>
> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130922/2a7ee705/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hegaeiid.png
Type: image/png
Size: 408 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130922/2a7ee705/attachment-0001.png>
------------------------------
Message: 5
Date: Sun, 22 Sep 2013 11:49:03 +0200
From: "Rene@gmail" <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] HXT followingSiblingAxis && transform on
this and the thing before
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hello,
I'd like to move around and transform some nodes in the following structure:
<vol>
<col pg="1" s="a"/>
<art><p>Text of article 1</p></art>
<art><p>Text of article 2</p></art>
<col pg="1" s="b"/>
<art><p>Text of article 3</p></art>
<art><p>Text of article 4</p></art>
</vol>
Namely, I want to move COL in between each of the next two (or more)
ART-Tags (<art><col../>...</art>. (So maybe "move" is the wrong word. I
want to cut COL and paste it in multiple ART-Tags.) Plus when moving one
COL in, I'd like to give the corresponding ART a new attribute with a
counter (n="[1..]"), so that the articles in one column are numbered.
So, to begin with, how do I get a COL-milestone together with the
following ARTs (but of course without the next COL) ? (if that's the
right way to do what I want to do..)
I tried this:
{-# LANGUAGE TupleSections, Arrows, NoMonomorphismRestriction #-}
import Text.XML.HXT.Core
import Control.Arrow.ArrowNavigatableTree
file = "../auswahl_few16.xml"
main = do
runX (configSysVars [withCanonicalize no, withValidate no, withTrace 0,
withParseHTML no] >>>
readDocument [withErrors no, withWarnings no] file
//> hasName "col" >>> addNav >>> followingSiblingAxis >>> remNav >>>
putXmlTree "-")
Which gives me an empty list. Then this:
//> (hasName "col" <+> (addNav >>> followingSiblingAxis >>> remNav)) >>>
putXmlTree "-"
And there are my old results for COL, but again nothing for the siblings.
In fact, it seems I have no clue, how to use followingSiblingAxis, and
then again if it worked out, I'm not sure if my selection really is the
one I need (maybe I get the siblings then only -- without the COL?).
UPDATE: Thanks to this SO-Question
(http://stackoverflow.com/questions/4767430/xpath-axis-get-all-following-nodes-until),
using hxt-xpath I was able to evaluate
(//col)[1]/following-sibling::art [1 = count (preceding-sibling::col[1] |
(//col)[1])]
to the first pair of ART-siblings. So that's very nice, but again not
really what I want. I want to process every COL with its siblings and I
hope HXT-Arrows offers a somewhat elegant solution to this.
Thanks in advance,
Ren? T.
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 63, Issue 33
*****************************************