Science Fair Projects Ideas - J programming language

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

J programming language

The J programming language, developed in the early 90's by Ken Iverson and Roger Hui, is a synthesis of APL (also by Iverson) and the FP and FL functional programming languages created by John Backus (of FORTRAN, ALGOL, and BNF fame).

To avoid the problems faced by the special character set of APL, J requires only the basic ASCII character set, resorting to the use of dot and colon characters to extend the meaning of the basic characters available.

Being an array programming language, J is very terse and powerful, and is often found to be useful for mathematical and statistical programming, especially when performing operations on matrices.

Like the original FP/FL languages, J supports function-level programming (also known as higher-order functional programming), via its tacit programming features (note that function-level programming is not the same as functional programming).

Unlike most languages that support object-oriented programming, J's flexible hierarchichal namespace scheme (where every name exists in a particular locale) can be effectively used as a framework for both class-based and instance-based object oriented programming.

J is an non-von Neumann programming language that nevertheless allows the programmer to use von Neumann programming style when desired.


Contents

Hello world

'Hello world'

Examples

J is an extremely powerful language, and its programs can be very terse but even more cryptic. Here is a one-liner implementation of the quicksort algorithm:

  qsort =: ]`(($:@:((}.<:{.)#}.)),{.,($:@:((}.>{.)#}.)))@.(*@#)

(No, it is not Linear A script.) But if we define some intermediate mnemonic names (NB. introduces a comment, think Nota Bene):

  id        =: ]                                 NB. identity function
  choose    =: @.                                NB. conditional execution
  first     =: {.                                NB. first element of collection
  rest      =: }.                                NB. all elements but first of collection
  o         =: @:                                NB. function composition:  f o g (x)  =   f(g(x))
  void      =: [:
  sign      =: * : void                          NB. monadic only, void dyadic
  length    =: # : void                          NB. monadic only, void dyadic
  selfrom   =: void : #                          NB. dyadic only, void monadic
  notEmpty  =: sign o length                     NB. sign 0 = 0


Then the J qsort becomes much more readable:

  selLEF    =: (rest <: first) selfrom rest      NB. select Less-than or Equal to First
  selGTF    =: (rest >  first) selfrom rest      NB. select Greater-Than First
 
  qsort  =: id ` (($: o selLEF),first,($: o selGTF))  choose notEmpty

Note particularly that this is an anonymous recursive function. J provides the self reference operator $: to refer anonymously to the largest enclosing context. Very few languages are capable of expressing this.

The following expression (thanks to Roger Hui) computes n digits of pi and demonstrates the extended precision capabilities of J:

 n=.50                                           NB. set n as the number of digits required
 <.@o. 10x^n                                     NB. extended precision 10 to the nth * pi
314159265358979323846264338327950288419716939937510

Also have a look at Cliff Reiter's implementation of Conway's game of life at http://ww2.lafayette.edu/~reiterc/j/vector/vlife_index.html

Vocabulary

= Self-Classify • Equal =. Is (Local) =: Is (Global)
< Box • Less Than <. Floor • Lesser Of (Min) <: Decrement • Less Or Equal
> Open • Larger Than >. Ceiling • Larger of (Max) >: Increment • Larger Or Equal
_ Negative Sign / Infinity _. Indeterminate _: Infinity
 
+ Conjugate • Plus +. Real / Imaginary • GCD (Or) +: Double • Not-Or
* Signum • Times *. Length/Angle • LCM (And) *: Square • Not-And
- Negate • Minus -. Not • Less -: Halve • Match
% Reciprocal • Divide %. Matrix Inverse • Matrix Divide %: Square Root • Root
 
^ Exponential • Power ^. Natural Log • Logarithm ^: Power (u^:n u^:v)
$ Shape Of • Shape $. Sparse $: Self-Reference
~ ReflexPassive / EVOKE ~. Nub • ~: Nub Sieve • Not-Equal
| Magnitude • Residue |. Reverse • Rotate (Shift) |: Transpose
 
. DeterminantDot Product .. Even .: Odd
: Explicit / Monad-Dyad :. Obverse :: Adverse
, Ravel • Append ,. Ravel Items • Stitch ,: Itemize • Laminate
; Raze • Link ;. Cut ;: Words • Sequential Machine
 
# Tally • Copy #. Base 2 • Base #: Antibase 2 • Antibase
! Factorial • Out Of !. Fit (Customize) !: Foreign
/ InsertTable /. ObliqueKey /: Grade Up • Sort
\ PrefixInfix \. SuffixOutfix \: Grade Down • Sort
 
[ Same • Left   [: Cap
] Same • Right    
{ Catalogue • From {. Head • Take {: Tail •   {:: Map • Fetch
} Item Amend • Amend (m} u}) }. Behead • Drop }: Curtail •
 
" Rank (m"n u"n m"v u"v) ". Do • Numbers ": Default Format • Format
` Tie (Gerund)   `: Evoke Gerund
@ Atop @. Agenda @: At
& Bond / Compose &. &.: Under (Dual) &: Appose
? Roll • Deal ?. Roll • Deal (fixed seed)
 
a. Alphabet a: Ace (Boxed Empty) A. Anagram Index • Anagram
b. Boolean / Basic C. Cycle-Direct • Permute d. Derivative/td>
D. Derivative D: Secant Slope e. Raze In • Member (In)
E. • Member of Interval f. Fix H. Hypergeometric
 
i. Integers • Index Of i: Integers • Index Of Last I. Indices •
j. Imaginary • Complex L. Level Of L: Level At
m. n. Explicit Noun Arguments NB. Comment o. Pi Times • Circle Function
p. Polynomial p.. Poly. Deriv. • Poly. Integral p: Primes •
 
q: Prime Factors • Prime Exponents   r. Angle • Polar s: Symbol
S: Spread t. Taylor Coefficient t: Weighted Taylor
T. Taylor Approximation u. v. Explicit Verb Arguments u: Unicode
x. y. Explicit Arguments x: Extended Precision _9: to 9: Constant Functions

See also

Function-level programming
Related programming languages:  APL, FP, FL, NGL, K

External links

  • JSoftware Creators of J (currently free for all uses)
  • Cliff Reiter Chaos, fractals and mathematical symmetries... in J
  • Ewart Shaw Bayesian inference, medical statistics, and numerical methods, using J
  • Keith Smillie Statistical applications of array programming languages, especially J
  • John Howland Research on parallelization of array programming languages, especially J

10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice