Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old November 7th, 2003, 09:55 AM
pennywise812002 pennywise812002 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 pennywise812002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Help With A Problem!

Hello to all!
I'm really sorry to bother you all but I'm banging my head with this task from at least a week and I don't know how to solve this problem
Basically I'm using HOPE language (I hope that anyone here is a bit familiar with this functional language!!) and my task is to define a function call precedens which takes two words and evaluates to true if the 1st word is alphabetically less than the second but both words have to be coverted in capital using a function called shout.
I have to use 2 functions within the function precedens which I defined but I cannot link them all in one
This is what I've done up to now...

dec islower : char ->truval;
--- islower x<= (x>='a') and (x=<'z');

dec convforlower : char->char;
--- convforlower x<= chr(ord(x)-32);

dec convtoupper : char->char;
--- convtoupper x<= if islower x = true
then convforlower x
else x;

the functions above will check if a character is in lower case and if it is this char will be converted in upper case.
The one below using the above functions will convert a list of char into uppercase and this is one of the 2 function that I have to use in precedens.

dec shout : list char ->list char;
--- shout nil<= nil;
--- shout (h::tail)<= convtoupper h :: shout(tail);


The one below is the 2nd function that I have to use in precedens
that will get two list of char (2 words) and will check if the 1st word is alphabetically less then the 2nd.

dec pre : list char # list char -> truval;
--- pre (anylist, nil)<= false;
--- pre (nil, h2::tail2)<=true;
--- pre (h1::tail1, h2::tail2) <= if h1=h2
then pre (tail1, tail2)
else h1<h2;


This is the one that doesn'e work!!
This function will get 2 lists of char and check if the 1st one is alphabetically less then the 2nd. However before I can do this I have to connvert every char into uppercase... and this is my BIG PROBLEM!!!!

dec precedens : list char # list char ->truval
--- precedens (h1::tail1, h2::tail2)<= shout (h1:: tail1)
shout (h2:: tail2)
pre (h1::tail1, h2::tail2);

I really hope that someone will give me a bit of help!!

THANK YOU VRY MUCH IN ADVANCE!!!!

Reply With Quote
  #2  
Old November 7th, 2003, 10:16 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
I'd be happy to help, unfortunatly i've never heard of HOPE.. a quick search on google also turned up nothing (except a few referances to Pascal). If you have a few links i could read up on it and maybe give you a hand, no promises

Oh while i think about it you may get a better responce if you post this in the general forum, surly somone on devshed must know this lang'

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old November 7th, 2003, 11:05 AM
Random Random is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 65 Random User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 39 m 56 sec
Reputation Power: 5
Hi Mark,

This is a link that I found for "Hope"
http://www.soi.city.ac.uk/~ross/Hope/

Random

Reply With Quote
  #4  
Old November 7th, 2003, 11:09 AM
pennywise812002 pennywise812002 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 pennywise812002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by netytan
I'd be happy to help, unfortunatly i've never heard of HOPE.. a quick search on google also turned up nothing (except a few referances to Pascal). If you have a few links i could read up on it and maybe give you a hand, no promises

Oh while i think about it you may get a better responce if you post this in the general forum, surly somone on devshed must know this lang'

Mark.


Hi thanks a lot!
I know there is not a lot on the net about this lang'
I'm studing it I guess because of the strong use of functions...
Anyway where do you think i could post this message?
I had a look but there is just a list of different languages...
I'll try to find something that can give you a bit more of help...

Reply With Quote
  #5  
Old November 7th, 2003, 11:15 AM
lazy_yogi lazy_yogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 325 lazy_yogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 36 sec
Reputation Power: 6
Re: Help With A Problem!

Try this.. you might need to edit it since I don't know the language. I've used other functional languages before tho.

Notice the fact I spent time on thinking of a function name that explains the function almost entirely and so you don't need to read any comments or the code to understand what it does. Make this a habbit. The few seconds spent on it saves enourmous time later when u have to read large programs to understand what it all does and how it works.

Code:

dec isLower : char -> truval;
--- isLower x<= (x>='a') and (x=<'z');

dec upperChar : char -> char;
--- upperChar x<= if isLower x = true
                  then chr(ord(x)-32);
                  else x;

dec upperStr : list char -> list char;
--- upperStr nil    <= nil;
--- upperStr (h::t) <= upperChar h :: upperStr(t);                      
            
dec compare : list char # list char -> truval;
--- compare (anylist, nil)   <= false;
--- compare (nil, anylist)   <= true; 
--- compare (h1::t1, h2::t2) <= if h1=h2
                                then compare (t1, t2);
                                else h1 < h2;  

dec precedens : list char # list char -> truval
--- precedens (list1, list2)<= upperStr list1
                               upperStr list2
                               compare (list1, list2); 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Help With A Problem!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway