Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #23652
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Build a random DNA sequence |
| Date | 2013-06-15 21:56 +0200 |
| Organization | 1&1 Internet AG |
| Message-ID | <kpigst$goj$1@online.de> (permalink) |
| References | <kjsddu$js9$1@dont-email.me> <kpfrto$4bh$1@dont-email.me> |
WJ wrote:
> WJ wrote:
>
>>
>> Factor:
>>
>> USING: locals random ;
>>
>> :: make-random-dna-sequence ( size -- seq )
>> { } size [ { "A" "T" "G" "C" } random suffix ] times ;
>>
>> 15 make-random-dna-sequence .
>> { "G" "T" "T" "T" "G" "G" "C" "T" "A" "A" "A" "T" "T" "G" "T" }
>
> Ruby:
>
> Array.new(13) { ['A','T','G','C'][ rand(4)] }
> ==>["G", "C", "G", "C", "C", "A", "A", "G", "A", "T", "G", "G", "G"]
>
> Can this feasibly be done in Forth?
Sure. I'd use a simple string for this, as the four letters are just
letters:
require random.fs
: random-dna ( size -- addr u ) dup allocate throw swap
2dup bounds DO s" ATGC" random + c@ I c! LOOP ;
13 random-dna type
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Build a random DNA sequence "WJ" <w_a_x_man@yahoo.com> - 2013-06-14 19:46 +0000
Re: Build a random DNA sequence Bernd Paysan <bernd.paysan@gmx.de> - 2013-06-15 21:56 +0200
Re: Build a random DNA sequence Alex McDonald <blog@rivadpm.com> - 2013-06-15 16:30 -0700
csiph-web