LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Closed Thread
 
LinkBack Search this Thread
Old 02-13-2012, 05:18 AM   #1
sapto
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Rep: Reputation: Disabled
Generate SPECIAL alphanumeric wordlist!!! Output!


can you help me about this???


#!/usr/bin/clisp

(defparameter *character-set* "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
;(defparameter *character-set* "ABC") ; < --- this line is for testing

(defparameter *word-length* 10)
;(defparameter *word-length* 4) ; < --- this line is for testing

(defparameter *character-list*
(coerce *character-set* 'list))

(defun final-char (in-string)
(cond
((> (length in-string) 0)
(elt in-string (1- (length in-string))))
(t
nil)))

(defun new-char-list (in-string)
(let ((result))
(mapcar
(lambda (candidate)
(cond
((not (eql candidate (final-char in-string)))
(push candidate result))))
*character-list*)
(nreverse result))
)

(defun extend-string (in-string desired-length)
(mapcar
(lambda (new-char)
(let ((new-string (concatenate 'string in-string (string new-char))))
(cond
((> (length new-string) desired-length))
((>= (length new-string) desired-length)
(format t "~a~%" new-string))
(t
(extend-string new-string desired-length)))))
(new-char-list in-string)))

(extend-string "" *word-length*)



When I want to output in .txt format, output file can be very large. Is it possible to, for example, after 100 mb, creates a new output files also in .txt? Thanks a lot!
 
Old 02-13-2012, 08:29 AM   #2
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian
Posts: 401

Rep: Reputation: 187Reputation: 187
Hi.

If you want to split output of your script into chunks of fixed size, try
Code:
$ ./gen.lisp | split -l10 -d - name
Where `gen.lisp' is your program, `-l10' each chunk is of 10 lines length, `-d' -- use numeric suffixes, `-' -- read from standard input, `name' -- prefix for created files. Read `man split' for details.

If you need more control over file names or something, try the following (almost equivalent) command
Code:
$ ./gen.lisp | (sleep 0.1; for((i=0; i<10; i++)); do dd of=$(printf "name_%.4d.txt" $i) bs=110 count=1; done)
Read `man dd', `help for', `man printf' for details.

I apologize if I misunderstood your question.

Last edited by firstfire; 02-13-2012 at 10:25 AM. Reason: Remove 'iflag=sync' -- it was an experiment.
 
Old 02-13-2012, 09:07 AM   #3
sapto
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thanks a lot, you have helped me. Is it possible that the program above, changes to: two characters that I wish can't be to each other in word.. example : I don't want that z and y be a neighbors:

abczyab unacceptable
abyzaba unacceptable
abyazab acceptable
 
Old 02-13-2012, 10:57 AM   #4
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian
Posts: 401

Rep: Reputation: 187Reputation: 187
Hi.

The simplest aproach is to filter out unnecessary words:
Code:
$ ./gen.lisp  | grep -iv 'zy\|yz'
'-i' stands for 'case-insensitive', '-v' means to invert match. So we remove words with either 'ZY' or 'YZ'.
 
Old 02-13-2012, 03:35 PM   #5
sapto
LQ Newbie
 
Registered: Feb 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by firstfire View Post
Hi.

The simplest aproach is to filter out unnecessary words:
Code:
$ ./gen.lisp  | grep -iv 'zy\|yz'
'-i' stands for 'case-insensitive', '-v' means to invert match. So we remove words with either 'ZY' or 'YZ'.
When I run 2 codes at the same time (./gen.lisp | split -l100000 -d - list &);(./gen.lisp | grep -iv 'zy\|yz' &)
I don't get what I want. I get only the words starting at z and y. Is there a way to start the two codes simultaneously and work well?
 
Old 02-13-2012, 04:49 PM   #6
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 332

Rep: Reputation: 118Reputation: 118
Quote:
Originally Posted by sapto View Post
When I run 2 codes at the same time (./gen.lisp | split -l100000 -d - list &);(./gen.lisp | grep -iv 'zy\|yz' &)
I don't get what I want. I get only the words starting at z and y. Is there a way to start the two codes simultaneously and work well?
Could you actually post your questions in only one thread? It is hard to follow the discussion when you post everything twice. Thank you.

the other thread is here
 
Old 02-14-2012, 08:08 AM   #7
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,755

Rep: Reputation: 88
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Generate SPECIAL alphanumeric WORDLIST - no repeating characters side-by-side Stanley_212 Programming 28 02-13-2012 09:13 PM
Generate SPECIAL alphanumeric WORDLIST with a total amount of consonants, number, ut0ugh1 Programming 2 10-26-2011 02:59 PM
Generate alphanumeric characterlist - no repeating more then 3 times jumpingj Programming 2 04-06-2011 04:55 AM
generate xml from nmap output shourya21 Linux - Newbie 1 01-24-2008 08:54 AM


All times are GMT -5. The time now is 04:37 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration