ontolog-forum
[Top] [All Lists]

Re: [ontolog-forum] HOL decidability [Was: using SKOS for controlled val

To: "[ontolog-forum] " <ontolog-forum@xxxxxxxxxxxxxxxx>, Rich Cooper <rich@xxxxxxxxxxxxxxxxxxxxxx>
From: Bill Andersen <andersen@xxxxxxxxxxxxx>
Date: Wed, 13 Oct 2010 15:52:19 -0400
Message-id: <B43536E6-242D-4373-A413-8451B1FF3D26@xxxxxxxxxxxxx>
On Oct 13, 2010, at 01:56 , Rich Cooper wrote:

Hi Duane, yes, iterators in software were what I tried to convey there.  There is no function that will iterate the primes.  By pairing each prime in ascending order with any other iterated set, you create unique prime keys for each element of that set, keys that cannot be factored.  
 
Thanks for your inputs,
-Rich

Hi Rich

Here's a fixed precision implementation of a prime iterator, along the lines Chris Menzel described.

Enjoy
------------

package foo;

import java.util.Iterator;

public class PrimeIterator implements Iterator<Integer> {

private Integer n = 2;


@Override
public boolean hasNext() {
// Thanks to Euclid :-D
return true;
}


private boolean isPrime(Integer n) {
Integer i = 2;
while (i < n) {
if ((n % i) == 0) {
// divisible by i < n
return false;
}
i++;
}
return true;
}

@Override
public Integer next() {
while (!isPrime(n)) {
n++;
}
Integer tmp = n;
n++;
return tmp;
}

@Override
public void remove() {
throw new UnsupportedOperationException();
}


public static void main(String[] argz) {
PrimeIterator iter = new PrimeIterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
}

}

Bill Andersen 
Highfleet, Inc. (www.highfleet.com)
3600 O'Donnell Street, Suite 600
Baltimore, MD 21224
Office: +1.410.675.1201
Cell: +1.443.858.6444
Fax: +1.410.675.1204






_________________________________________________________________
Message Archives: http://ontolog.cim3.net/forum/ontolog-forum/  
Config Subscr: http://ontolog.cim3.net/mailman/listinfo/ontolog-forum/  
Unsubscribe: mailto:ontolog-forum-leave@xxxxxxxxxxxxxxxx
Shared Files: http://ontolog.cim3.net/file/
Community Wiki: http://ontolog.cim3.net/wiki/ 
To join: http://ontolog.cim3.net/cgi-bin/wiki.pl?WikiHomePage#nid1J
To Post: mailto:ontolog-forum@xxxxxxxxxxxxxxxx    (01)

<Prev in Thread] Current Thread [Next in Thread>