Roughly, equivalents of 
  puts     and gets   in C are
  smoutput and prompt in J. Thus we have:

NB. =========================================================
require 'misc'  NB. prompt

main=: 3 : 0
  while.1 do.
    'x y'=. ":&.>[EMAIL PROTECTED]
    'op'=. ({~ [EMAIL PROTECTED])'+-*'
    if. 0=#z=. 0".prompt (exp=. x,op,y),' = ' 
      do.'Bye!'break.end.
    smoutput (10#' '),(z=".exp)>@{'Wrong';'Correct!'
  end.
)
NB. =========================================================

The above snippet can pasted into a new
J window and run, or into jconsole, or loaded like below.

   load 'd:\math\j601\temp\8.ijs'
   main''
6-8 = -2
          Correct!
12*8 = 96
          Correct!
3*12 = 1
          Wrong
3+10 = 13
          Correct!
11*4 = 44
          Correct!
10-5 = 
Bye!


--- Amelia Stein <[EMAIL PROTECTED]> wrote:

> I have read the manuals, and most of jsoftware.com without success.  From
> what I have found the manuals only explain the primitives, and verb
> definitions.  I don't want to write a verb that I have to pass arguments
> to.  I don't want to write a one line definition.  I want to write a driver
> function essentially.  The function should have user prompts that explain
> what type of data to enter ect.  I want to write a script the equivalent of
> this C code in J:
> 
> //Written in C
> # include <stdio.h>
> int main (void)
> {
> int i,x;
> printf ("Enter a number:");
> scanf("%d", &i);
> x=call_on_function_that_I_still_have_to_write(i);
> printf("%d", x);
> return 0;
> }



       
____________________________________________________________________________________
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to