Luke,
This is the typical bottled response to people asking for homework
help. But spot135 has done a good job so far: stated his problems,
shown his work so far, asking for guidance not answers. And the
community has done a good job helping: no answers, but hints and
leading questions. I wo
spot135 writes:
> So this is what ive got so far.
>
> data Tree a = Empty | Leaf a | Branch a [Tree a]
[Homework mode on, i.e. hints and careful nudges to help you work it out
on your own]
The definition above gives two ways to build a Tree with only one data
element. Can you see which ones?
On Mon, Nov 9, 2009 at 12:31 AM, Stefan Holdermans wrote:
>> Answers to spec.
>
>
> You didn't answered the "homework" question:
>
>>> I don't know if this is homework.
>
> I'm a bit suspicious:
> http://www.dcs.shef.ac.uk/intranet/teaching/modules/level2/com2010.html .
>
> See http://www.haskell
Answers to spec.
You didn't answered the "homework" question:
I don't know if this is homework.
I'm a bit suspicious: http://www.dcs.shef.ac.uk/intranet/teaching/modules/level2/com2010.html
.
See http://www.haskell.org/haskellwiki/Homework_help .
Cheers,
Stefan
Actually, let me clarify my point: I have rarely encountered problems
when using Cabal as a package distribution system, but I have run into
problems when using it as a build system in a non-trivial manner. For
example, when I wanted to build a lot of small utility programs I
found that i
I have rarely encountered problems when creating or installing
packages using Cabal. In fact, the opposite is the case: I find it
annoying when installing packages that haven't been cabalized because
they don't pull in all of their dependencies automatically.
It looks like there was a pro
I made small improvements in the Small Japi Binding, and asked how to make it
available. I received a few private messages advising me to build and package
the library using a tool called cabal. Since I have used installation tools for
PLT, R and LaTeX libraries, I thought cabal was something s
One of this differences between Haskell and Clean I did not see
mentioned in
this discussion is that Clean does not allow so-called partial
parametrisation. I.e. all function calls have to be fully saturated
I think there may be a misunderstanding here.
Beware: I haven't used Clean in a w
Hi Casey,
Answers to spec.
the tree is not ordered, it holds string varying in length.
the element value is given, but not its location ie (replace "Two" "Five"
Tree a) would find the location of element "Two" and replace it with "Five"
the tree is not balanced, Nodes can have other Nodes com
Am Sonntag 08 November 2009 23:24:59 schrieb spot135:
> Hi,
>
> Ok what im trying to do is replace an element in an n-ary and display the
> completed tree.
>
> So this is what ive got so far.
>
> data Tree a = Empty |Leaf a|Branch a [Tree a]
> deriving (Show)
>
replac
I don't know if this is homework.
I suppose what you mean is the following: I'm trying to replace an
element in an n-ary tree and display the completed tree.
A more precise specification might help.
- is the tree ordered
- are all the elements in the leaves (not internal nodes)
- is the location
On Sun, 8 Nov 2009 15:07:45 -0800 (PST), you wrote:
>Hi Casey,
>
>I was already aware of the translation thing, but didn't want to complicate.
>
>Lot's of ways to skin a cat. I wrote a Lispy solution, then had the feeling I
>could improve on it w/Haskell. Picking the right tool takes practice.
>
Anybody? thanks
spot135 wrote:
>
>
> Hi,
>
> Ok what im trying to do is replace an element in an n-ary and display the
> completed tree.
>
> So this is what ive got so far.
>
> data Tree a = Empty |Leaf a|Branch a [Tree a]
> deriving (Show)
>
>
> replace :
Akshay Dave wrote:
> I undertsand that this is Haskell cafe discussion forum. But
> I would highly appreciate if anyone can tell me where can I get
> Compiler and editor for FLow Caml ( it's a ML based language)) as
> I am not able to find it on net :(.
I suggest that the ocaml mailing list w
Hi Casey,
I was already aware of the translation thing, but didn't want to complicate.
Lot's of ways to skin a cat. I wrote a Lispy solution, then had the feeling I
could improve on it w/Haskell. Picking the right tool takes practice.
Thanks,
Michael
--- On Sun, 11/8/09, Casey Hawthorne wrot
Sorry, I forgot to add that if the polygon is very far from the
origin, you may have overflow or increased round off error; it is
better to translate the polygon back to the origin, before doing the
area calculation.
How about these BETTER type signatures.
-- Area of a Polygon
import Data.L
Hello,
I undertsand that this is Haskell cafe discussion forum. But I would highly
appreciate if anyone can tell me where can I get Compiler and editor for FLow
Caml ( it's a ML based language)) as I am not able to find it on net :(.
Thanks in Adavnce!
Akshay
Hi,
Ok what im trying to do is replace an element in an n-ary and display the
completed tree.
So this is what ive got so far.
data Tree a = Empty |Leaf a|Branch a [Tree a]
deriving (Show)
replace :: Eq a=>a->a->Tree a -> (Tree a)
replace x y Empty = Element x
Hi everybody,
We're less than one week away from the third Darcs Hacking Sprint, taking place
in Portland and in Vienna on 14-15 November.
Everybody is welcome (Haskell and Darcs newbies included), but please do let us
know if you're thinking of attending!
Preflight checklist
---
wxHaskell contains functions to read and write images, for example
imageGetPixels [1] and imageCreateFromPixelArray [2]
Met vriendelijke groet,
Henk-Jan van Tuyl
[1]
http://hackage.haskell.org/packages/archive/wxcore/0.10.13.0/doc/html/Graphics-UI-WXCore-Image.html#v:imageGetPixels
[2]
h
How about these BETTER type signatures.
-- Area of a Polygon
import Data.List
type X = Double
type Y = Double
type Area = Double
poly1 = [(0,1),(5,0),(3,4)]::[(X,Y)]
areaPoly :: [(X,Y)] -> Area
areaPolyCalc :: (Area,(X,Y)) -> (X,Y) -> (Area,(X,Y))
areaPoly
How about these type signatures.
import Data.List
poly1 = [(0,1),(5,0),(3,4)]::[(Double,Double)]
areaPoly :: [(Double,Double)] -> Double
areaPolyCalc :: (Double,(Double,Double)) -> (Double,Double) ->
(Double,(Double,Double))
areaPoly (pt:pts) = 0.5 * (fst (fold
2009/11/8 Matthew Gruen :
> On Sun, Nov 8, 2009 at 6:21 AM, Deniz Dogan
> wrote:
>> What point are you trying to make by distinguishing JSON from
>> JavaScript? JSON is a subset of JavaScript, they share the same type
>> system. "Null can be only one value." This doesn't make sense to me,
>> since
I see what one problem is, what happens when I end up with (x,y):[]? However,
I'm confused about how Haskell is "expecting" and "inferring" upon compilation.
Michael
--- On Sun, 11/8/09, michael rice wrote:
From: michael rice
Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl
To: "Chad
That's certainly better than mine, but I'm lost again, with the following. What
seemed like a simple improvement doesn't compile.
Michael
===
This works.
area :: [(Double,Double)] -> Double
area ps = abs $ (/2) $ area' (last ps) ps
where area' _ [] = 0
On Sun, Nov 8, 2009 at 6:21 AM, Deniz Dogan
wrote:
> What point are you trying to make by distinguishing JSON from
> JavaScript? JSON is a subset of JavaScript, they share the same type
> system. "Null can be only one value." This doesn't make sense to me,
> since as you say null is not a type, bu
Hi,
I'm thinking of trying to get a devroom for haskell.org at the next
FOSDEM, which is Saturday-Sunday February 6th-7th 2010 in Brussels:
http://www.fosdem.org/2010/call-developer-rooms
The idea would be to try to introduce Haskell to people at FOSDEM who were
interested, and thus help bui
On Sun, Nov 8, 2009 at 9:04 PM, michael rice wrote:
> Of course! Back to the drawing board.
>
>
If I understand the problem correctly, I'm not convinced that foldl is the
right approach (nevermind that foldl is almost never what you want, foldl'
and foldr being the correct choice almost always).
Thank you for that answer. All I could find out is that the file that
causes the alarm is named "folder.exe" (size: 82kb). I don't know for
sure what that is, but since I don't need the package I simply deleted
it. Probably it was just a coincidence that I had some trojan problems
just after zi
Philippos Apolinarius writes:
> Could you tell me what should I do to make my version and examples available?
1) Make sure it builds with cabal.
2) Upload it to Hackage
And optionally,
3) make the darcs repository available on the web
The process is nicely described here:
http://www.haskel
Ketil Malde wrote:
> If nothing else, perhaps you would make your modifications available?
> That way, the next JAPI user will have less trouble than you did.
> (Assming the license allows it, of course.)
JAPI license allows it. In fact, it is one of the most liberal licenses I saw.
It says:
Of course! Back to the drawing board.
Thanks,
Michael
--- On Sun, 11/8/09, Eugene Kirpichov wrote:
From: Eugene Kirpichov
Subject: Re: [Haskell-cafe] Area from [(x,y)] using foldl
To: "michael rice"
Cc: haskell-cafe@haskell.org
Date: Sunday, November 8, 2009, 2:56 PM
The type of foldl is:(b
The type of foldl is:
(b -> a -> b) -> b -> [a] -> b
What do you expect 'a' and 'b' to be in your algorithm?
2009/11/8 michael rice
> Here's an (Fortran) algorithm for calculating an area, given one
> dimensional
> arrays of Xs and Ys. I wrote a recursive Haskell function that works, and
> one
Here's an (Fortran) algorithm for calculating an area, given one dimensional
arrays of Xs and Ys. I wrote a recursive Haskell function that works, and one
using
FOLDL that doesn't. Why would Haskell be "expecting" (t, t) out of ((*)
(xold-x) (yold+y))?
Michael
AREA = 0
On Sun, Nov 08, 2009 at 04:34:26PM +0200, Max Rabkin wrote:
> To add image support to fdo-notify, I need an image type. Looking
> through Hackage, I didn't find any image library with the following
> features:
> * Load from a variety of formats (at least PNG and JPG, I'd say)
> * Efficient per-pixe
Max Rabkin wrote:
On Sun, Nov 8, 2009 at 5:09 PM, Max Rabkin wrote:
On Sun, Nov 8, 2009 at 4:58 PM, Andrew Coppin
wrote:
Try AC-EasyRaster-GTK.
Thanks, I'll give that a try
Having downloaded it, I must admit I was a bit put off by seeing things like
init_system :: IO ()
Hi,
thanks to all for all the helpful answers and references. Maybe I'll try
to collect them into a wiki page, if I have time. It looks like that I'm
not the only one facing this problem and many people know different
tricks how to handle it.
Yes, I was thinking about using lists of pairs ins
On Sun, 2009-11-08 at 16:34 +0200, Max Rabkin wrote:
> To add image support to fdo-notify, I need an image type. Looking
> through Hackage, I didn't find any image library with the following
> features:
> * Load from a variety of formats (at least PNG and JPG, I'd say)
> * Efficient per-pixel acces
> "Jeremy" == Jeremy Shaw writes:
Jeremy> There is a partial binding to libgd:
Jeremy>
http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html
Jeremy> http://www.libgd.org/Main_Page
Jeremy> But GD itself may not do what you want.
I ended up using
Max Rabkin wrote:
Haskellers,
To add image support to fdo-notify, I need an image type. Looking
through Hackage, I didn't find any image library with the following
features:
* Load from a variety of formats (at least PNG and JPG, I'd say)
* Efficient per-pixel access, or a way to dump the image
There is a partial binding to libgd:
http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html
http://www.libgd.org/Main_Page
But GD itself may not do what you want.
- jeremy
On Nov 8, 2009, at 8:34 AM, Max Rabkin wrote:
Haskellers,
To add image support to fdo-notif
> "Max" == Max Rabkin writes:
Max> Haskellers, To add image support to fdo-notify, I need an
Max> image type. Looking through Hackage, I didn't find any image
Max> library with the following features: * Load from a variety of
Max> formats (at least PNG and JPG, I'd say) * Effi
Haskellers,
To add image support to fdo-notify, I need an image type. Looking
through Hackage, I didn't find any image library with the following
features:
* Load from a variety of formats (at least PNG and JPG, I'd say)
* Efficient per-pixel access, or a way to dump the image into a
ByteString as
In fact, I could simply write a fibonacci function like this :
fibonacci n=
fst $ fib n Map.empty
where
fib 0 m=(0,m)
fib 1 m=(1,m)
fib n m=
case Map.lookup n m of
Just x->(x,m)
Nothing->
let (n',m')=memoMap (n-2) m
(
On Sun, Nov 8, 2009 at 2:51 AM, Pierre-Etienne Meunier
wrote:
> Hi,
>
> I'm designing an algorithm that uses dynamic programming. I've written it
> with an array, and it works, but it is still very slow and needs way too
> much memory.
>
> Then I realized that the array was very sparse (at most a
This seems related:
http://en.wikipedia.org/wiki/Semigroup_action
But I'm not entirely sure.
Sjoerd
On Nov 7, 2009, at 7:57 PM, Neil Brown wrote:
Hi,
We have names for properties of operators/functions. For example,
if this holds:
a % b = b % a
for some operator %, we say that % is com
Jon Fairbairn writes:
> The "empty" type in Haskell would be (forall a.a) which has no
> non-bottom values.
With an extension, you can also define:
data Void -- without any constructors
which is perhaps closer to null types in other languages?
-k
--
If I haven't seen further, it is by s
2009/11/7 Matthew Gruen :
> Forgot to cc haskell-cafe. Trying again:
>
> -- Forwarded message --
> From: Matthew Gruen
> Date: Sat, Nov 7, 2009 at 2:16 PM
> Subject: Re: [Haskell-cafe] Is () a 0-length tuple?
> To: Pasqualino Titto Assini
>
> On Sat, Nov 7, 2009 at 2:00 PM, Pasqua
"Pasqualino \"Titto\" Assini" writes:
> The syntax is similar, but what else is?
What would you expect from an empty tuple?
(a,b,c) has a constructor function p3 a b c = (a,b,c) and three
destructor functions s3_1 (a,b,c) = a, s3_2 (a,b,c) = b and s3_3 (a,b,c)=c
(a,b) has a constructor functio
How about this?
{-# LANGUAGE ThinkTotal #-}
On 8 Nov 2009, at 09:53, Svein Ove Aas wrote:
On Sun, Nov 8, 2009 at 9:52 AM, Ketil Malde wrote:
Eugene Kirpichov writes:
In JavaScript there is a "null" value, that is the only value of
the null type.
Isn't () the same thing? The only value
On Sun, Nov 8, 2009 at 9:52 AM, Ketil Malde wrote:
> Eugene Kirpichov writes:
>
>>> In JavaScript there is a "null" value, that is the only value of the null
>>> type.
>>> Isn't () the same thing? The only value of the unary type?
>
>> No, () has two values: () and undefined (t.i., _|_).
>
How
Hi,
I'm designing an algorithm that uses dynamic programming. I've written
it with an array, and it works, but it is still very slow and needs
way too much memory.
Then I realized that the array was very sparse (at most a O(\sqrt(n))
of its size is actually used). Now I want to rewrite it
My impression is the saturated-ness that Doaitse speaks of is covered
in Urban Boquist's phd thesis on the GRIN intermediate language -
circa page 31.
http://www.cs.chalmers.se/~boquist/phd/
As per the code snippet above Clean handles partial application
entirely adequately.
Best wishes
Stephen
Philippos Apolinarius writes:
> So, I searched for JAPI bindings for Haskell. The only library I found
> was something called Small Japi binding for GHC. The package is
> incomplete, and bug ridden.
I don't know anything about this particular library, but this happens.
Now that we have Cabal
Why speak nonsense when you can test it?
//
module nonsense
import StdEnv
nonsense = map ((^) 2)
Start = nonsense [1,2,3]
//
Running
Eugene Kirpichov writes:
>> In JavaScript there is a "null" value, that is the only value of the null
>> type.
>> Isn't () the same thing? The only value of the unary type?
> No, () has two values: () and undefined (t.i., _|_).
I'd argue that yes, they're the same thing, since any function re
Hi,
Thanks for the replies so far. If it helps, after I sent my post, I
spotted a couple of arithmetic examples:
Neil Brown wrote:
2: (a % b) % c = (a % c) % b
Division (on rationals) obeys this property (a / b) / c = (a / c) / b --
which is actually equal to a / (b * c), but that doesn't m
L Spice writes:
>> Doaitse Swierstra wrote:
>>>One of this differences between Haskell and Clean I did not see mentioned in
>>> this discussion is that Clean does not allow so-called partial
>>> parametrisation. I.e. all function calls have to be fully saturated
>> I don't understand what you m
58 matches
Mail list logo