Prism Helper
Tokens
| Token |
Example |
| keyword |
import { stuff } from 'some/where.js';
|
| builtin |
pi = round(float('3.14159'), 2)
|
| class-name |
class Wizard extends Human { /* ... */ }
|
| function |
function helloGrumpy(name) { /* ... */ }
helloGrumpy('Wizard');
|
| parameter |
function helloGrumpy(name) { /* ... */ }
|
| boolean |
const wizardsLikeBeer = false;
|
| number |
const favouriteNumber = 3.14159;
|
| string |
const hiGrumpy = 'Hi Grumpy!';
|
| template-string, template-punctuation |
const hiGrumpy = `Hi Grumpy!`;
|
| interpolation, interpolation-punctuation |
console.log(`Hi there ${name}.`);
|
| char |
|
| symbol |
|
| regex |
let entity = /&#x?[\da-f]{1,8};/;
|
| url |
body { background: url("wizard.png"); }
|
| operator |
x += (y + 4 >> -z === w) ? b ** c : ~a;
|
| variable |
DECLARE @MyCounter INT;
|
| constant |
const PI = 3.14159;
|
| property |
.grumpy > img { height: 100%; }
|
| punctuation |
import { stuff } from 'some/where.js';
|
| important |
.grumpy > img { height: 100% !important; }
|
| comment |
/* grump wizards */
|
| tag |
<h1>Grumpy Wizards</h1>
|
| attr-name, attr-value |
<h1 class="dangerous">Grumpy Wizards</h1>
|
| namespace |
throw new java.lang.UnsupportedOperationException();
|
| prolog |
<?xml version="1.0" encoding="utf-8"?>
|
| doctype |
<!DOCTYPE html>
|
| cdata |
<![CDATA[ grumpy wizards eat donuts ]]>
|
| entity |
£ £
|
| atrule |
@media (prefers-reduced-motion: reduce) { /* no animations */ }
|
| selector |
.grumpy > img { /* ... */ }
|
| null |
{ "fritter": null }
|
| color |
background-color: rgba(0, 0, 0, 0.4);
border: 1px solid #cd2026;
|
Language Samples
// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
delay(1); // delay in between reads for stability
}
AREA ARMex, CODE, READONLY
; Name this block of code ARMex
ENTRY ; Mark first instruction to execute
start
MOV r0, #10 ; Set up parameters
MOV r1, #3
ADD r0, r0, r1 ; r0 = r0 + r1
stop
MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SVC #0x123456 ; ARM semihosting (formerly SWI)
END ; Mark end of file
#!/bin/bash
if [ -d $directory ]; then
echo "Directory exists"
else
echo "Directory does not exists"
fi
#include <stdio.h>
int main() {
char c;
printf("Enter a character: ");
scanf("%c", &c);
// %d displays the integer value of a character
// %c displays the actual character
printf("ASCII value of %c = %d", c, c);
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int divisor, dividend, quotient, remainder;
cout << "Enter dividend: ";
cin >> dividend;
cout << "Enter divisor: ";
cin >> divisor;
quotient = dividend / divisor;
remainder = dividend % divisor;
cout << "Quotient = " << quotient << endl;
cout << "Remainder = " << remainder;
return 0;
}
using System;
namespace Method {
class Program {
// method declaration
public void display() {
Console.WriteLine("Hello World");
}
static void Main(string[] args) {
// create class object
Program p1 = new Program();
//call method
p1.display();
Console.ReadLine();
}
}
}
.grumpy > img {
background-image: url("smile.png");
height: 100%;
width: var(--some-var);
}
@font-face {
font-family: 'Lato';
font-style: normal;
src: local('Lato Regular');
}
@media (prefers-reduced-motion: reduce) {
:host([opened]), :host([opened-above]) {
animation: none !important;
}
}
{-# START_FILE main.hs #-}
import System.IO
main = do
handle <- openFile "file.txt" ReadMode
contents <- hGetContents handle
putStr contents
hClose handle
{-# START_FILE file.txt #-}
Hello, world!
import System.Random
main = (randomRIO (1, 100) :: IO Int) >>= print
public class VowelConsonant {
public static void main(String[] args) {
char ch = 'i';
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' )
System.out.println(ch + " is vowel");
else
System.out.println(ch + " is consonant");
}
}
/* grumpy javascript */
import { stuff } from 'some/where.js';
function helloGrumpy(name) {
console.log(`Hi there ${name}.`);
}
class Wizard extends Human { }
const grumpy = new Wizard();
let wizardFoods = [...donuts, ... cakes, ...pies];
const wizardsLikeBeer = false;
const favouriteNumber = 3.14159;
const PI = 3.14159;
const regex = /[^\w\s]/g; // regex, regex-delimiter, regex-source, regex-flag
{
"jinxed": "gnomes",
"grumpy": [ "wizards" ],
"jelly": 99,
"donut": true,
"fritter": null
}
fun main(args: Array) {
val a = 2.3
val b = 4
val c = 5.6
val root1: Double
val root2: Double
val output: String
val determinant = b * b - 4.0 * a * c
// condition for real and different roots
if (determinant > 0) {
root1 = (-b + Math.sqrt(determinant)) / (2 * a)
root2 = (-b - Math.sqrt(determinant)) / (2 * a)
output = "root1 = %.2f and root2 = %.2f".format(root1, root2)
}
// Condition for real and equal roots
else if (determinant == 0.0) {
root2 = -b / (2 * a)
root1 = root2
output = "root1 = root2 = %.2f;".format(root1)
}
// If roots are not real
else {
val realPart = -b / (2 * a)
val imaginaryPart = Math.sqrt(-determinant) / (2 * a)
output = "root1 = %.2f+%.2fi and root2 = %.2f-%.2fi".format(realPart, imaginaryPart, realPart, imaginaryPart)
}
println(output)
}
\begin{aligned} \nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\ \nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\ \nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned}
P(E) = {n \choose k} p^k (1-p)^{ n-k}
\begin{aligned} \dot{x} & = \sigma(y-x) \\ \dot{y} & = \rho x - y - xz \\ \dot{z} & = -\beta z + xy \end{aligned}
<!DOCTYPE html> <!-- doctype, doctype-tag, name -->
<html>
<body class="typography">
<![CDATA[ some cdata section ]]>
<div style="color: blue;">
£
£
</div>
</body>
</html>
for n = 1:5
x = n*0.1;
z = myfunc2(x,2,3,7);
fprintf('x = %4.2f f(x) = %8.4f \r',x,z)
end
# Program to check if a number is prime or not
num = 29
# To take input from the user
#num = int(input("Enter a number: "))
# define a flag variable
flag = False
# prime numbers are greater than 1
if num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
# if factor is found, set flag to True
flag = True
# break out of loop
break
# check if flag is True
if flag:
print(num, "is not a prime number")
else:
print(num, "is a prime number")
# decimal variable
num = as.integer(readline(prompt = "Enter a number: "))
# num = 15
isPrime = 0
if (num > 1) {
isPrime = 1
for (i in 2: (num - 1)) {
if ((num %% i) == 0) {
isPrime = 0
break
}
}
}
if (num == 2) isPrime = 1
if (isPrime == 1) {
print(paste(num, "is a prime number"))
} else {
print(paste(num, "is not a prime number"))
}
(define (rgb-maker mk)
(lambda (sz)
(vc-append (colorize (mk sz) "red")
(colorize (mk sz) "green")
(colorize (mk sz) "blue"))))
(\W|^)[\w.\-]{0,25}@(yahoo|hotmail|gmail)\.com(\W|$)
(\W|^)po[#\-]{0,1}\s{0,1}\d{2}[\s-]{0,1}\d{4}(\W|$)
^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$
\b(?:word1\W+(?:\w+\W+){1,6}?word2|word2\W+(?:\w+\W+){1,6}?word1)\b
^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
DECLARE @MyCounter INT; /* keyword, variable, punctuation */
SELECT AVG(Calories) AS AverageCalories FROM Desserts;
SELECT * FROM Desserts
SET ROWCOUNT 4;
SET @Hidden = FALSE;
SET @Donuts = 'Yummy';
CloudDeploy[
FormFunction[FormObject[{"ImageURL" -> "String"}],
ImageEffect[
ColorConvert[
ImageMultiply[
ColorConvert[
ImageAdd[ImageAdjust[Import[#ImageURL], .2],
RGBColor[.25, .25, -.1]], "HSB"], Hue[1, .7, 1]],
"RGB"], {"PoissonNoise", .5}] &, "JPEG"],
Permissions -> "Public"]
More Samples (Web Component Scope)