Skip to content

Commit 6a6586a

Browse files
committed
chore: add more language samples
1 parent 53b01e7 commit 6a6586a

File tree

16 files changed

+308
-0
lines changed

16 files changed

+308
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
∇ FizzBuzz end;i
2+
:For i :In ⍳end
3+
:If 0=15|i
4+
⎕←'FizzBuzz'
5+
:ElseIf 0=3|i
6+
⎕←'Fizz'
7+
:ElseIf 0=5|i
8+
⎕←'Buzz'
9+
:Else
10+
⎕←i
11+
:EndIf
12+
:EndFor
13+
14+
15+
⎕ ← data ← (1 2 3 4) (2 5 8 6) (8 6 2 3) (8 7 6 1)
16+
17+
]dinput
18+
Sum ← {
19+
⍺ ← 0 ⍝ Left arg defaults to 0 if not given
20+
0=≢⍵: ⍺ ⍝ If right arg is empty, return left arg
21+
(⍺+⊃⍵)∇1↓⍵ ⍝ Add head to acc, recur over tail
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
TBSCertificate ::= SEQUENCE {
2+
version [0] Version DEFAULT v1,
3+
serialNumber CertificateSerialNumber,
4+
signature AlgorithmIdentifier,
5+
issuer Name,
6+
validity Validity,
7+
subject Name,
8+
subjectPublicKeyInfo SubjectPublicKeyInfo,
9+
issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,
10+
-- If present, version MUST be v2 or v3
11+
subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,
12+
-- If present, version MUST be v2 or v3
13+
extensions [3] Extensions OPTIONAL
14+
-- If present, version MUST be v3 -- }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(ns hello-world.core)
2+
3+
(println "Hello world!")
4+
5+
;; ADDED
6+
(defn average [a b]
7+
(/ (+ a b) 2.0))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(defclass bicycle (vehicle)
2+
((mass :reader bicycle-mass
3+
:initarg :mass
4+
:type real
5+
:documentation "The bike's mass."))
6+
(:documentation "A bicycle."))
7+
8+
(defclass canoe (vehicle)
9+
((rowers :reader canoe-rowers
10+
:initarg :rowers
11+
:initform 0
12+
:type (integer 0)
13+
:documentation "The number of rowers."))
14+
(:documentation "A canoe."))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import std.stdio;
2+
3+
int x = 10;
4+
immutable int y = 30;
5+
const int* p;
6+
7+
pure int purefunc(int i,const char* q,immutable int* s) {
8+
//writeln("Simple print"); //cannot call impure function 'writeln'
9+
10+
debug writeln("in foo()"); // ok, impure code allowed in debug statement
11+
// x = i; // error, modifying global state
12+
// i = x; // error, reading mutable global state
13+
// i = *p; // error, reading const global state
14+
i = y; // ok, reading immutable global state
15+
auto myvar = new int; // Can use the new expression:
16+
return i;
17+
}
18+
19+
void main() {
20+
writeln("Value returned from pure function : ",purefunc(x,null,null));
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- Show a list of items I need to buy at the grocery store.
2+
--
3+
4+
import Html exposing (..)
5+
6+
7+
main =
8+
div []
9+
[ h1 [] [ text "My Grocery List" ]
10+
, ul []
11+
[ li [] [ text "Black Beans" ]
12+
, li [] [ text "Limes" ]
13+
, li [] [ text "Greek Yogurt" ]
14+
, li [] [ text "Cilantro" ]
15+
, li [] [ text "Honey" ]
16+
, li [] [ text "Sweet Potatoes" ]
17+
, li [] [ text "Cumin" ]
18+
, li [] [ text "Chili Powder" ]
19+
, li [] [ text "Quinoa" ]
20+
]
21+
]

projects/dev-app/src/assets/lang_samples/javascript.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
'use strict';
2+
13
/**
24
* foo
5+
*
36
* @param {string[]} items
47
* @param nada
58
*/
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function f(x, y)
2+
x[1] = 42 # mutates x
3+
y = 7 + y # new binding for y, no mutation
4+
return y
5+
end
6+
7+
fib(n::Integer) = n ≤ 2 ? one(n) : fib(n-1) + fib(n-2)
8+
9+
map([A, B, C]) do x
10+
if x < 0 && iseven(x)
11+
return 0
12+
elseif x == 0
13+
return 1
14+
else
15+
return x
16+
end
17+
end
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
% This is a template for doing homework assignments in LaTeX
2+
3+
\documentclass{article} % This command is used to set the type of document you are working on such as an article, book, or presenation
4+
5+
\usepackage{geometry} % This package allows the editing of the page layout
6+
\usepackage{amsmath} % This package allows the use of a large range of mathematical formula, commands, and symbols
7+
\usepackage{graphicx} % This package allows the importing of images
8+
9+
\newcommand{\question}[2][]{\begin{flushleft}
10+
\textbf{Question #1}: \textit{#2}
11+
12+
\end{flushleft}}
13+
\newcommand{\sol}{\textbf{Solution}:} %Use if you want a boldface solution line
14+
\newcommand{\maketitletwo}[2][]{\begin{center}
15+
\Large{\textbf{Assignment #1}
16+
17+
Course Title} % Name of course here
18+
\vspace{5pt}
19+
20+
\normalsize{Matthew Frenkel % Your name here
21+
22+
\today} % Change to due date if preferred
23+
\vspace{15pt}
24+
25+
\end{center}}
26+
\begin{document}
27+
\maketitletwo[5] % Optional argument is assignment number
28+
%Keep a blank space between maketitletwo and \question[1]
29+
30+
\question[1]{Here is my first question}
31+
32+
YOUR SOLUTION HERE
33+
34+
\question[2]{Here is my second question}
35+
36+
YOUR SOLUTION HERE
37+
38+
\question[3]{What is the \Large{$\int_0^2 x^2 \, dx $}\normalsize{. Show all steps}}
39+
40+
\begin{align*}
41+
\int_0^2 x^2 &= \left. \frac{x^3}{3} \right|_0^2 \\
42+
&= \frac{2^3}{3}-\frac{0^3}{3}\\
43+
&= \frac{8}{3}
44+
\end{align*}
45+
\end{document}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- If customer.name = "anonymous" -->
2+
{% if customer.name == "kevin" %}
3+
Hey Kevin!
4+
{% elsif customer.name == "anonymous" %}
5+
Hey Anonymous!
6+
{% else %}
7+
Hi Stranger!
8+
{% endif %}
9+
10+
{% assign handle = "cake" %}
11+
{% case handle %}
12+
{% when "cake" %}
13+
This is a cake
14+
{% when "cookie", "biscuit" %}
15+
This is a cookie
16+
{% else %}
17+
This is not a cake nor a cookie
18+
{% endcase %}

0 commit comments

Comments
 (0)