Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

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:
  #1  
Old December 7th, 2009, 03:12 PM
brogers614 brogers614 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2009
Posts: 9 brogers614 Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 43 m 58 sec
Reputation Power: 0
Lisp Help

Hello, I am new to programming, I am working on an assignment I have 3/4 done and can’t figure out the rest here are the requirements

The program reads the text from the named file and outputs a scrambled version of the text in which:
1. All but the first and the last letters in every word (defined as a contiguous sequence of alphabetic characters) are permuted randomly.
2. All other characters (numbers and punctuations) remain unchanged.

I have another file that has a paragraph of text with punctuation… I guess I can’t figure out these parts
1. Create a handle-alpha function that:
a. takes a stream argument (in) and a character argument (c),
b. read more alphabetic characters from the stream until you hit a non-alphabetic character or end of file,
c. form a list from c and the alphabetic characters read,
d. if the list contains 4 or more characters, shuffle all but the first and the last characters in the list,
e. convert the list back to a string,
f. print the resulting string,
g. return the first non-alphabetic character that follows the word.

Here is my code...Thanks… If you can’t help me thank you for reading this.



(defun scramble (test.lisp) ; my scramble function takes a string argument
(with-open-file (in test.lisp) ; open the named file
(setq c (read-char in nil)) ; read the first character from the file
(loop ; repeat until return
(setq nc ; set the next character
(cond ; depending on 3 cases of the current character
((null c) (return nil)) ; 1: end of file -> exit the loop
((alpha-char-p c) (handle-alpha in c)) ; 2: alphabetic -> call handle-alpha
(t (format t "~a" c) ; 3: non-alphabetic -> print it
(setq c (read-char in nil)) ; and read the next character
)
)) ; end cond and setq nc
(setq c nc) ; next character becomes current character for next iteration
) ; end loop
)) ; end with-open-file and defun

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Lisp Help

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap