Help in Haskell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Help in Haskell

Andre Paulo Machado
Hi folks..... Somebody could help me, please?

Please, I would like a help in haskell programming, because I have with
following question:

I need to create a list of strings, like as a graph.
See:

initiaList = [ ("BSB,"SSA"),
                   ("CNF","SSA"),
                   ("CNF","GIG"),
                   ("CNF","GRU"),
                   ("GIG","CNF"),
                   ("GIG","GRU"),
                   ("GRU","BSB"),
                   ("GRU","GIG"),
                   ("GRU","CNF"),
                   ("SSA","CNF") ]

With this list above, I will create a function that returns a path with max
number of links:
example:

maxLink = 4 (result until 4)

command:   myFunction "BSB"  "GRU" 4
result:          1st Option:   BSB -> SSA -> CNF -> GRU
                    2nd Option:  BSB -> SSA -> CNF -> GIG -> GRU
----------------------------------------------------------------------------
command:   myFunction "BSB"  "GRU" 3
result:          1st Option:   BSB -> SSA -> CNF -> GRU
----------------------------------------------------------------------------

How do this?
I'm waiting from you,
thank you so much.

Andre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20081124/5af12ad8/attachment.htm
Reply | Threaded
Open this post in threaded view
|

Re: Help in Haskell

Benjamin L. Russell
This looks like a homework question.  While we are all here to help
you figure out a solution, it would be unethical just to give you a
solution to a homework problem; rather, we are here to help you figure
out the solution yourself.

As such, first, please follow the homework help procedure outlined in
"Homework help - HaskellWiki" (see
http://www.haskell.org/haskellwiki/Homework_help) (substitute
"haskell-beginners or haskell-cafe" for "haskell-cafe," and just
ignore the part about the existence of "stupid questions"--there is no
such thing as a "stupid question"; however, there are such things as
appropriate questions and inappropriate questions, and in order for us
to help you appropriately in this context, you need to show us more
specifically what you have done and where you are stuck, so that we
can provide help that would be appropriate in this context).

Specifically, please follow the following procedure first:

>   1.  Read the problem carefully and make sure you understand what is being asked of you.
>   2. If you can't solve the whole problem, try breaking the problem down into parts and solving those parts.
>   3. If you can't write it in Haskell, try writing it in English (or your native language) first.
>   4. If you can't write code, try at least writing a type signature.
>   5. Look through the libraries provided by Haskell, particularly those parts which have been pointed out to you in class or in your course notes. There may be something there which helps you.

If you are still stuck, then it might be useful to follow the
following steps from the procedure listed on the above-mentioned
homework help page:

>   4. Try to make your question as specific as possible. Say what problem (or subproblem) you are stuck on as succinctly as you can. If the original homework question is long, don't copy it verbatim (though if it's available on the web, a link couldn't hurt).
>   5. Say what you've done so far, and include code. People are much more likely to help you fix your incorrect code than write correct code for you. Moreover, if the problem is that you don't understand something, your incorrect code will probably reflect this, and fixing your misunderstanding is much more valuable than fixing your code.

In the above-mentioned procedure, the more detail you provide, the
more helpful we can be in our hints.

-- Benjamin L. Russell

On Mon, 24 Nov 2008 05:04:12 -0200, "Andre Paulo Machado"
<[hidden email]> wrote:

>Hi folks..... Somebody could help me, please?
>
>Please, I would like a help in haskell programming, because I have with
>following question:
>
>I need to create a list of strings, like as a graph.
>See:
>
>initiaList = [ ("BSB,"SSA"),
>                   ("CNF","SSA"),
>                   ("CNF","GIG"),
>                   ("CNF","GRU"),
>                   ("GIG","CNF"),
>                   ("GIG","GRU"),
>                   ("GRU","BSB"),
>                   ("GRU","GIG"),
>                   ("GRU","CNF"),
>                   ("SSA","CNF") ]
>
>With this list above, I will create a function that returns a path with max
>number of links:
>example:
>
>maxLink = 4 (result until 4)
>
>command:   myFunction "BSB"  "GRU" 4
>result:          1st Option:   BSB -> SSA -> CNF -> GRU
>                    2nd Option:  BSB -> SSA -> CNF -> GIG -> GRU
>----------------------------------------------------------------------------
>command:   myFunction "BSB"  "GRU" 3
>result:          1st Option:   BSB -> SSA -> CNF -> GRU
>----------------------------------------------------------------------------
>
>How do this?
>I'm waiting from you,
>thank you so much.
>
>Andre

Reply | Threaded
Open this post in threaded view
|

Homework help (was Re: Help in Haskell)

ajb@spamcop.net
G'day Benjamin.

Quoting "Benjamin L.Russell" <[hidden email]>:

> As such, first, please follow the homework help procedure outlined in
> "Homework help - HaskellWiki" (see
> http://www.haskell.org/haskellwiki/Homework_help) (substitute
> "haskell-beginners or haskell-cafe" for "haskell-cafe," and just
> ignore the part about the existence of "stupid questions"--there is no
> such thing as a "stupid question"; however, there are such things as
> appropriate questions and inappropriate questions, and in order for us
> to help you appropriately in this context, you need to show us more
> specifically what you have done and where you are stuck, so that we
> can provide help that would be appropriate in this context).

It's a wiki.  If the wording is bad, fix it!

Cheers,
Andrew Bromage
Reply | Threaded
Open this post in threaded view
|

Re: Homework help (was Re: Help in Haskell)

Benjamin L. Russell
On Wed, 26 Nov 2008 18:18:45 -0500, [hidden email] wrote:

>G'day Benjamin.
>
>Quoting "Benjamin L.Russell" <[hidden email]>:
>
>> As such, first, please follow the homework help procedure outlined in
>> "Homework help - HaskellWiki" (see
>> http://www.haskell.org/haskellwiki/Homework_help) (substitute
>> "haskell-beginners or haskell-cafe" for "haskell-cafe," and just
>> ignore the part about the existence of "stupid questions"--there is no
>> such thing as a "stupid question"; however, there are such things as
>> appropriate questions and inappropriate questions, and in order for us
>> to help you appropriately in this context, you need to show us more
>> specifically what you have done and where you are stuck, so that we
>> can provide help that would be appropriate in this context).
>
>It's a wiki.  If the wording is bad, fix it!

Actually, initially I had to fight the urge not to rewrite it in a
less elitist manner, in order to avoid the possibility of offending
the original author.

In fact, I had been thinking about changing that page since about
December of 2007, when I think I first saw it, but had hesitated out
of a concern that doing so would have gone against the intent of the
original author of that page.  On a related issue, I had previously
encountered a number of participants on Haskell-Cafe who had reacted
negatively against what they apparently thought were "stupid
questions":  One of them even asked (in private e-mail) that a
participant not "pollute" Haskell-Cafe by asking about whether screen
resolution was important in determining the precision of an algorithm
to compute prime numbers by picking points randomly from a square.  

I refrained from changing the page because of the possibility that the
original author may have been an elitist, who could have changed it
back immediately.

Part of my original purpose in suggesting the creation of
Haskell-Beginners was to create a more non-elitist, beginner-friendly
atmosphere.

More specifically, since HaskellWiki is also visible to participants
on Haskell-Cafe, and not just to those on Haskell-Beginners, if I
changed the original intent of the sentence by rephrasing the
following sentence (see
http://www.haskell.org/haskellwiki/Homework_help):

>Your lecturer/instructor may have told you that there is no such thing as a stupid question. Inside your classroom, that is correct. Outside your classroom, there are smart questions and stupid questions. If you ask a smart question of the Haskell community, you will probably get a helpful answer. If you ask a stupid question, you will probably get an unhelpful answer or, more likely, no answer at all.

to the following sentence:

>Your lecturer/instructor may have told you that there is no such thing as a stupid question. Indeed, that is correct. However, independent of the context, there are appropriate questions and inappropriate questions. If you first attempt to solve a problem with a decent amount of effort, then get stuck, and then ask for a hint from the Haskell community, your question will most likely be viewed as appropriate, and you will probably get a helpful answer. If you do not attempt to solve the problem, but try to get somebody else to solve the entire problem for you, your question will most likely be viewed as inappropriate, and you will probably get an unhelpful answer or, more likely, no answer at all.

I could have risked going against the cultural attitude of the
original author, who had deliberately used the pejorative term "stupid
question."  The term "stupid" has certain condescending connotations
that are not suggested by the relatively neutral term "inappropriate."
Perhaps those connotations had actually been deliberate, and not
coincidental, in which case changing the connotations could have
started a revision war, which I didn't want.

I disagree with the cultural attitude suggested by the term "stupid
question."  To me, there is no such thing as a "stupid question."  If
somebody asks an inappropriate question, it should be sufficient just
not to answer the question, or to suggest an alternative question,
rather than to respond in a hostile or condescending manner.

Nevertheless, this is just my personal opinion.  Everybody is entitled
to an opinion.  I didn't change the original wording, even though I
had to fight a desperate urge to do so, because I had thought that the
original author had just as much right to his/her wording as I did to
mine, and I wasn't sure if possibly changing the original intent, as
opposed to just the original wording, was appropriate.  However, if I
had been the original author, I would have definitely worded the
sentence in a less elitist manner.

-- Benjamin L. Russell

Reply | Threaded
Open this post in threaded view
|

Re: Homework help (was Re: Help in Haskell)

Benjamin L. Russell
Nevertheless, there is such a thing as a consensus, and given the role
of this mailing list, it does seem that rewriting the "Homework help -
HaskellWiki" page in a more egalitarian manner may be worth a try.
After all, any changes can be immediately reversed, and I can't see
any harm in rewriting the page in a more beginner-friendly manner.

Therefore, I have taken the liberty of revising the above-mentioned
HaskellWiki page in a less elitist manner, which had long been my
eventual intent.

We'll see what happens.  With luck, the new egalitarian tone will
stay.

-- Benjamin L. Russell

On Thu, 27 Nov 2008 16:44:34 +0900, Benjamin L.Russell
<[hidden email]> wrote:

>On Wed, 26 Nov 2008 18:18:45 -0500, [hidden email] wrote:
>
>>G'day Benjamin.
>>
>>Quoting "Benjamin L.Russell" <[hidden email]>:
>>
>>> As such, first, please follow the homework help procedure outlined in
>>> "Homework help - HaskellWiki" (see
>>> http://www.haskell.org/haskellwiki/Homework_help) (substitute
>>> "haskell-beginners or haskell-cafe" for "haskell-cafe," and just
>>> ignore the part about the existence of "stupid questions"--there is no
>>> such thing as a "stupid question"; however, there are such things as
>>> appropriate questions and inappropriate questions, and in order for us
>>> to help you appropriately in this context, you need to show us more
>>> specifically what you have done and where you are stuck, so that we
>>> can provide help that would be appropriate in this context).
>>
>>It's a wiki.  If the wording is bad, fix it!
>
>Actually, initially I had to fight the urge not to rewrite it in a
>less elitist manner, in order to avoid the possibility of offending
>the original author.
>
>In fact, I had been thinking about changing that page since about
>December of 2007, when I think I first saw it, but had hesitated out
>of a concern that doing so would have gone against the intent of the
>original author of that page.  On a related issue, I had previously
>encountered a number of participants on Haskell-Cafe who had reacted
>negatively against what they apparently thought were "stupid
>questions":  One of them even asked (in private e-mail) that a
>participant not "pollute" Haskell-Cafe by asking about whether screen
>resolution was important in determining the precision of an algorithm
>to compute prime numbers by picking points randomly from a square.  
>
>I refrained from changing the page because of the possibility that the
>original author may have been an elitist, who could have changed it
>back immediately.
>
>Part of my original purpose in suggesting the creation of
>Haskell-Beginners was to create a more non-elitist, beginner-friendly
>atmosphere.
>
>More specifically, since HaskellWiki is also visible to participants
>on Haskell-Cafe, and not just to those on Haskell-Beginners, if I
>changed the original intent of the sentence by rephrasing the
>following sentence (see
>http://www.haskell.org/haskellwiki/Homework_help):
>
>>Your lecturer/instructor may have told you that there is no such thing as a stupid question. Inside your classroom, that is correct. Outside your classroom, there are smart questions and stupid questions. If you ask a smart question of the Haskell community, you will probably get a helpful answer. If you ask a stupid question, you will probably get an unhelpful answer or, more likely, no answer at all.
>
>to the following sentence:
>
>>Your lecturer/instructor may have told you that there is no such thing as a stupid question. Indeed, that is correct. However, independent of the context, there are appropriate questions and inappropriate questions. If you first attempt to solve a problem with a decent amount of effort, then get stuck, and then ask for a hint from the Haskell community, your question will most likely be viewed as appropriate, and you will probably get a helpful answer. If you do not attempt to solve the problem, but try to get somebody else to solve the entire problem for you, your question will most likely be viewed as inappropriate, and you will probably get an unhelpful answer or, more likely, no answer at all.
>
>I could have risked going against the cultural attitude of the
>original author, who had deliberately used the pejorative term "stupid
>question."  The term "stupid" has certain condescending connotations
>that are not suggested by the relatively neutral term "inappropriate."
>Perhaps those connotations had actually been deliberate, and not
>coincidental, in which case changing the connotations could have
>started a revision war, which I didn't want.
>
>I disagree with the cultural attitude suggested by the term "stupid
>question."  To me, there is no such thing as a "stupid question."  If
>somebody asks an inappropriate question, it should be sufficient just
>not to answer the question, or to suggest an alternative question,
>rather than to respond in a hostile or condescending manner.
>
>Nevertheless, this is just my personal opinion.  Everybody is entitled
>to an opinion.  I didn't change the original wording, even though I
>had to fight a desperate urge to do so, because I had thought that the
>original author had just as much right to his/her wording as I did to
>mine, and I wasn't sure if possibly changing the original intent, as
>opposed to just the original wording, was appropriate.  However, if I
>had been the original author, I would have definitely worded the
>sentence in a less elitist manner.
>
>-- Benjamin L. Russell

Reply | Threaded
Open this post in threaded view
|

Re: Homework help (was Re: Help in Haskell)

Tillmann Rendel-2
In reply to this post by Benjamin L. Russell
Benjamin L.Russell wrote:

> I refrained from changing the page because of the possibility that the
> original author may have been an elitist, who could have changed it
> back immediately.
>
> [...]
>
> I could have risked going against the cultural attitude of the
> original author, who had deliberately used the pejorative term "stupid
> question."  The term "stupid" has certain condescending connotations
> that are not suggested by the relatively neutral term "inappropriate."
> Perhaps those connotations had actually been deliberate, and not
> coincidental, in which case changing the connotations could have
> started a revision war, which I didn't want.
>
> [...]
>
> I wasn't sure if possibly changing the original intent, as opposed to
> just the original wording, was appropriate.

As I understand them, the point of a wiki in general and the Haskell
wiki in particular is to involve readers with developing not only the
wording, but also the content and underyling ideas of the texts. I would
therefore consider changing the original intent as not generally
inappropriate.

Moreover, you do not start an edit war by editing, you start or continue
an edit war by reverting again and again. If the original author decides
to revert your change, you can still avoid an edit war by not reverting
the revert.

   Tillmann
Reply | Threaded
Open this post in threaded view
|

Re: Homework help (was Re: Help in Haskell)

ajb@spamcop.net
In reply to this post by Benjamin L. Russell
G'day all.

Quoting "Benjamin L.Russell" <[hidden email]>:

> Actually, initially I had to fight the urge not to rewrite it in a
> less elitist manner, in order to avoid the possibility of offending
> the original author.

It was me, and I'm not offended.  By putting words on a Wiki, rather
than, say, a personal blog, I feel that I'm explicitly inviting others
to be bold and modify them.

> I could have risked going against the cultural attitude of the
> original author, who had deliberately used the pejorative term "stupid
> question."

Actually, the reason why I used that term is simpler than that: I'd
just read the "smart questions" FAQ, and my brain was pre-conditioned
in that direction.

Go ahead and change it.

Cheers,
Andrew Bromage