3ygbcbxe2 

3ygbcbxe2 


Output:

Step:  0   process-1    0   0   0   0
Step:  1   process-3    1   0   0   0
Step:  2   process-1    1   0   7   0
Step:  3   process-3    2   0   7   0
Step:  4   process-2    2   0  14   0
Step:  5   process-3    2   1  14   0
Step:  6   process-1    2   1  14   0
Step:  7   process-4    3   1  14   0
Step:  8   process-2    3   1  14   1
Step:  9   process-4    3   3  14   1
Step: 10   process-2    3   3  14   2
Step: 11   process-3    3   6  14   2
Step: 12   process-1    3   6  14   2
Step: 13   process-4    4   6  14   2
Step: 14   stop         4   6  14   3
----------------------------------------------------------------
Step:  9   process-4    3   3  14   1
Step: 10   process-2    3   3  14   2
Step: 11   process-3    3   6  14   2
Step: 12   process-1    3   6  14   2
Step: 13   process-4    4   6  14   2
Step: 14   stop         4   6  14   3
----------------------------------------------------------------

Racket Online Compiler

Write, Run & Share Racket code online using OneCompiler's Racket online compiler for free. It's one of the robust, feature-rich online compilers for Racket language, running on the latest version 6.8. Getting started with the OneCompiler's Racket compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as Racket and start coding.

Taking inputs (stdin)

OneCompiler's Racket online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Racket program which takes name as input and print your name with hello.

#lang racket/base
(define name (read))                
(printf "Hello ~a.\n" name)   

About Racket

Racket is a general-purpose programming language based on the Scheme dialect of Lisp. It is also used for scripting, computer science education, and research related applications.

Basics

ItemDecsription
;To comment a single line
;;to mark important comments
#;to comment the following s-expression

Data types

Data-typeDecsription
Numbersrepresents integers, float and complex numbers
Boolean#t and #f are the two boolean literals
StringsTo represent sequence of characters and double quotes("") are used to represent strings

Variables

let and define are used to declare variables

Syntax

(let ([id value-expression] ...) body ...+)

(let proc-id ([id init-expression] ...) body ...+)
define id expression

Example

> (let ([x 10]) x)
10

Loops and conditional statements

1. If family

If, If-else are used when you want to perform a certain set of operations based on conditional expressions.

If

(if cond-expr then-expr)

If-else

(if cond-expr then-expr else-expr)

2. For

For loop is used to iterate a set of statements based on a condition.

(for (for-clause ...) body-or-break ... body)
where 

for-clause = [id seq-expr] | [(id ...) seq-expr] | #:when guard-expr | #:unless guard-expr | break-clause
 	 	 	 	 
break-clause = #:break guard-expr | #:final guard-expr
 	 	 	 	 
body-or-break = body | break-clause

seq-expr : sequence?

Functions

A lambda expression is used to create a function.

(lambda (argument-id ...)
  body ...+)