Learn J - 10 Code Examples & CST Typing Practice Test
J is a high-level, general-purpose, array-oriented programming language designed for concise and expressive code. It emphasizes functional programming, tacit programming (point-free style), and powerful array operations, making it ideal for mathematical, statistical, and data-intensive computations.
Learn J with Real Code Examples
Updated Nov 20, 2025
Code Sample Descriptions
J Counter and Theme Toggle
count =: 0
isDark =: 0
updateUI =: 3 : 0
'Counter: ', ": count
'Theme: ', (if. isDark do. 'Dark' else. 'Light')
)
increment =: 3 : 0
count = count + 1
updateUI ''
)
decrement =: 3 : 0
count = count - 1
updateUI ''
)
reset =: 3 : 0
count = 0
updateUI ''
)
toggleTheme =: 3 : 0
isDark = 1 - isDark
updateUI ''
)
'Simulate actions'
updateUI ''
increment ''
increment ''
toggleTheme ''
decrement ''
reset ''
Demonstrates a simple counter with theme toggling using J variables and verbs.
J Fibonacci Sequence
fib =: 0 1
for_i. 8 do. fib =: fib , (+/@:1) fib ; end.
fib
Generates first 10 Fibonacci numbers using J array operations.
J Prime Checker
isPrime =: 3 : 0
n = y
n > 1 &. >./ n | i.1 + n - 2
)
Checks if a number is prime using J modulo and all/any verbs.
J Multiplication Table
n =: 5
(n * i.10) +: 'x ' , n
Generates multiplication table for a number using J.
J Celsius to Fahrenheit
c =: 25
f =: c * 9 % 5 + 32
f
Converts Celsius to Fahrenheit using J expressions.
J Simple Alarm Simulation
temp =: 80
thresh =: 75
if. temp > thresh do. 'Alarm: Temperature Too High!' else. 'Temperature Normal'
Simulates an alarm if temperature threshold is exceeded.
J Random Walk Simulation
steps =: 10
pos =: 0
for_i. steps do. pos = pos + (0 < ?2) * 2 - 1 ; pos end.
Simulates a 1D random walk using J random verbs.
Frequently Asked Questions about J
What is J?
J is a high-level, general-purpose, array-oriented programming language designed for concise and expressive code. It emphasizes functional programming, tacit programming (point-free style), and powerful array operations, making it ideal for mathematical, statistical, and data-intensive computations.
What are the primary use cases for J?
Mathematical and statistical computing. Array and matrix processing. Algorithm prototyping. Financial modeling and quantitative analysis. Data analysis and transformation
What are the strengths of J?
Extremely concise code for complex operations. Strong support for array and matrix manipulation. Ideal for prototyping mathematical algorithms. Interactive development encourages experimentation. Encourages functional, point-free programming paradigms
What are the limitations of J?
Steep learning curve due to symbolic syntax. Small community compared to mainstream languages. Limited general-purpose libraries for modern app development. Not well-suited for large-scale enterprise software. Keyboard and symbolic notation can be intimidating for beginners
How can I practice J typing speed?
CodeSpeedTest offers 10+ real J code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.