LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 686 users online 225142 members 922 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Shitler
Interests: Reading, writing, music (playing, w...
Mood: Devilish
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
6 online / 27 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Adding Reply

Adding Reply
Archived Topic: It will not be bumped to the top of the forum.
Topic OCaml help
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
Dangeresque Posted at 5:05 am on Sep. 10, 2006
Hey, I am new to this site.  I need some help debugging some OCaml code.  This is a simple Eratosthenes' prime sieve algorithm.  I can do this easily in C, C++, C#, Java, MATLAB, Ruby, and Python, but as I am learning OCaml as my first functional programming language I can't get this to compile.  I would really appreciate your help with this as a friend of mine recommended this site for teen programmers.  Thanks again.  Keep in mind that I am trying to keep this recursive.

let max = 1000 in
let primes = Array.create 1000 true in
let num = 2 in
let outer_func num =
 if num == sqrt.max then num  
 else if primes.(num) == true then
    let pos = num * num in
    let inner_func pos =
       if pos > max then pos
       else (
          primes.(pos)<-false;);
       inner_func (pos + num);
  outer_func (num + 1);
for counter = 2 to max do
  if primes.(counter) == true then
     print_line counter;
done;;

Replies
Whit3 Gangst3r Posted at 5:24 pm on Dec. 31, 2008
Dayummm, and no one replied... HAH!