Subj : Re: Dartmouth BASIC to C To : comp.programming From : Jon Harrop Date : Sat Aug 06 2005 08:46 pm John Smith wrote: > Having nothing better to do on a Saturday morning, I was looking at > Kemeny & Kurtz's 1964 manual for BASIC: > > http://www.bitsavers.org/pdf/dartmouth/BASIC_Oct64.pdf > > Below is a C port of the first example program given in the manual. Can > it be improved while preserving, as much as possible, the structure of > the original BASIC program? I've no idea, but here's an OCaml port, just for fun: $ ocaml Objective Caml version 3.08.3 # let a1, a2, a3, a4 = 1., 2., 4., 2. in let d = a1 *. a4 -. a3 *. a2 in if d = 0. then print_endline "NO UNIQUE SOLUTION" else let solve (b1, b2) = let x1 = (b1 *. a4 -. b2 *. a2) /. d in let x2 = (a1 *. b2 -. a3 *. b1) /. d in Printf.printf "%f %f\n" x1 x2 in List.iter solve [-7., 5.; 1., 3.; 4., -7.];; 4.000000 -5.500000 0.666667 0.166667 -3.666667 3.833333 - : unit = () -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com .