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.  GPIO/I2C/PWM and Haskell (Michal Kawalec)
   2. Re:  GPIO/I2C/PWM and Haskell (Michael Jones)
   3.  Project Euler #01 on HackerRank, Performance issue? (Jean Lopes)
   4. Re:  Project Euler #01 on HackerRank, Performance issue?
      (Brandon Allbery)
   5. Re:  Project Euler #01 on HackerRank, Performance issue?
      (Jean Lopes)
   6. Re:  Project Euler #01 on HackerRank, Performance issue?
      (Lyndon Maydwell)


----------------------------------------------------------------------

Message: 1
Date: Tue, 27 Jan 2015 15:45:44 +0100
From: Michal Kawalec <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] GPIO/I2C/PWM and Haskell
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Hey list,

I got myself a Beaglebone and will use it to stabilize and fly a drone
with Haskell. The ghc support seems good enough (text doesn't compile,
everything else does), but I have a question about inputs/outputs.

They are all set through sysfs, and I think a wrapper over it would be
easiest and most straightforward to have. The operation of most pins
goes along the lines of 'activate a pin -> do some stuff -> turn it
off'. Is there some particular mechanism/library you would suggest me to
look into to handle that? Any thoughts or own experience with doing
similar things with Haskell?


Any tips will be appreciated:)
Michal

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20150127/88e3da31/attachment-0001.sig>

------------------------------

Message: 2
Date: Tue, 27 Jan 2015 09:02:07 -0700
From: Michael Jones <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] GPIO/I2C/PWM and Haskell
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Michal,

I am doing similar things (not arial) on a MinnowBoardMax. Did not want to deal 
with ARM and Haskell. But if you make that work, I think it would be worth 
publishing how you did it. I struggled to build a cross compiler for ARM and 
gave up.

As for MinnowBoardMax, I am running Ubuntu with a 3.18.1 kernel and a solid 
state drive. A little heavy on the weight when you consider the batteries 
required to run a 5W system.

I have libraries for I2C, UART, and GPIO, but not published.

Here is an example of how I deal with ALERTB

module SMBusAlert (
  alert
) where

import System.IO

alert :: IO Bool
alert = do
        writeFile "/sys/class/gpio/export" "340"
        writeFile "/sys/class/gpio/gpio340/direction" "in"
        s <- readFile "/sys/class/gpio/gpio340/value"
        s `seq` writeFile "/sys/class/gpio/unexport" "340"
        if s!!0 == '0' then return True else return False


On Jan 27, 2015, at 7:45 AM, Michal Kawalec <[email protected]> wrote:

> Hey list,
> 
> I got myself a Beaglebone and will use it to stabilize and fly a drone
> with Haskell. The ghc support seems good enough (text doesn't compile,
> everything else does), but I have a question about inputs/outputs.
> 
> They are all set through sysfs, and I think a wrapper over it would be
> easiest and most straightforward to have. The operation of most pins
> goes along the lines of 'activate a pin -> do some stuff -> turn it
> off'. Is there some particular mechanism/library you would suggest me to
> look into to handle that? Any thoughts or own experience with doing
> similar things with Haskell?
> 
> 
> Any tips will be appreciated:)
> Michal
> 
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners




------------------------------

Message: 3
Date: Tue, 27 Jan 2015 21:29:22 -0200
From: Jean Lopes <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Project Euler #01 on HackerRank,
        Performance issue?
Message-ID:
        <CAKeoKsgMn_=RLwEF2ZE=hpwv0+qkxgxfzlnw7+qzqm0mzuc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello everyone! I'm learning Haskell by solving simple exercises on
www.hackerrank.com...


The problem to be solved:
https://www.hackerrank.com/contests/projecteuler/challenges/euler001

as stated in this section: https://www.hackerrank.com/environment
constraints
version: haskell-plataform 2013.2.0.0
time limit: 5 seconds
memory: 512mb

I keep getting "timed out" on some test cases (#2 and #3). Trying to
process 10^5 numbers between 1 to 10^9 *seems* impossible to me (Please,
prove me wrong!)

here is my code:
import Data.Maybe
import qualified Data.ByteString.Char8 as B

nearestMultipleOf :: Integral a => a -> a -> a
nearestMultipleOf n k = if mod n k == 0 then n else nearestMultipleOf (n-1)
k

sumMultiplesOf :: Integral a => a -> a -> a
sumMultiplesOf n k = foldl (+) 0 [k,k*2..nearest]
    where nearest = nearestMultipleOf n k

solution :: Integral a => a -> a
solution n = s03 + s05 - s15
    where s03 = sumMultiplesOf (n-1) 3
          s05 = sumMultiplesOf (n-1) 5
          s15 = sumMultiplesOf (n-1) 15

main = do
    c <- B.getContents
    let ns = tail $ B.lines c
    putStr $ unlines $ map show $ map (solution . fst . fromJust .
B.readInt) ns

as always, any input is really welcome!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20150127/e1fc1107/attachment-0001.html>

------------------------------

Message: 4
Date: Tue, 27 Jan 2015 18:38:31 -0500
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Project Euler #01 on HackerRank,
        Performance issue?
Message-ID:
        <cakfcl4wjprzc-w+jbvbptmbxocto33mwwn4rb4a_zrd6-us...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Tue, Jan 27, 2015 at 6:29 PM, Jean Lopes <[email protected]> wrote:

> The problem to be solved:
> https://www.hackerrank.com/contests/projecteuler/challenges/euler001


It's worth remembering that the Euler problems are all about math
understanding; often they are designed such that brute force solutions will
time out or otherwise fail.

-- 
brandon s allbery kf8nh                               sine nomine associates
[email protected]                                  [email protected]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20150127/6916043b/attachment-0001.html>

------------------------------

Message: 5
Date: Tue, 27 Jan 2015 21:57:23 -0200
From: Jean Lopes <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Project Euler #01 on HackerRank,
        Performance issue?
Message-ID:
        <CAKeoKshVYr=o+gwrg4ik+hyihuvp32cajlxwyvf5hr2hqp4...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I'm not really good at math, maybe I am missing something obvious ?
Maybe some pointers as of where to start studying math in order to avoid
this brute force attempts, at least to help in this particular problem

2015-01-27 21:38 GMT-02:00 Brandon Allbery <[email protected]>:

> On Tue, Jan 27, 2015 at 6:29 PM, Jean Lopes <[email protected]> wrote:
>
>> The problem to be solved:
>> https://www.hackerrank.com/contests/projecteuler/challenges/euler001
>
>
> It's worth remembering that the Euler problems are all about math
> understanding; often they are designed such that brute force solutions will
> time out or otherwise fail.
>
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> [email protected]
> [email protected]
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> 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/20150127/bc089a91/attachment-0001.html>

------------------------------

Message: 6
Date: Wed, 28 Jan 2015 11:11:53 +1100
From: Lyndon Maydwell <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Project Euler #01 on HackerRank,
        Performance issue?
Message-ID:
        <CAM5QZtzS01ekdaKds7efW8VKfZ2sNCTUyuCbLMpm0D2KQ=b...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I remember that when I had a look at Euler 1 I found that there's a fun
solution that should run in "constant" time.

You can find the sum of the multiples of 3, add the multiples of 5, and
then subtract the multiples of 3*5.

Is that the kind of thing you're looking for?

 - Lyndon


On Wed, Jan 28, 2015 at 10:57 AM, Jean Lopes <[email protected]> wrote:

> I'm not really good at math, maybe I am missing something obvious ?
> Maybe some pointers as of where to start studying math in order to avoid
> this brute force attempts, at least to help in this particular problem
>
> 2015-01-27 21:38 GMT-02:00 Brandon Allbery <[email protected]>:
>
>> On Tue, Jan 27, 2015 at 6:29 PM, Jean Lopes <[email protected]> wrote:
>>
>>> The problem to be solved:
>>> https://www.hackerrank.com/contests/projecteuler/challenges/euler001
>>
>>
>> It's worth remembering that the Euler problems are all about math
>> understanding; often they are designed such that brute force solutions will
>> time out or otherwise fail.
>>
>> --
>> brandon s allbery kf8nh                               sine nomine
>> associates
>> [email protected]
>> [email protected]
>> unix, openafs, kerberos, infrastructure, xmonad
>> http://sinenomine.net
>>
>> _______________________________________________
>> Beginners mailing list
>> [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/20150128/5cc7df5d/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 79, Issue 32
*****************************************

Reply via email to