Skip to content

Commit f92f52b

Browse files
committed
bam
1 parent 61cec1c commit f92f52b

File tree

3 files changed

+222
-205
lines changed

3 files changed

+222
-205
lines changed

v5-unity/js/example-links.ts

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
export var pythonExamples = `<p style="margin-top: 25px; font-weight: bold;">Python Examples</p>
2+
3+
<p style="margin-top: 10px;">Basic:
4+
5+
<a class="exampleLink" id="aliasExampleLink" href="#">hello</a> |
6+
<a class="exampleLink" id="happyExampleLink" href="#">happy</a> |
7+
<a class="exampleLink" id="tutorialExampleLink" href="#">intro</a> |
8+
<a class="exampleLink" id="filterExampleLink" href="#">filter</a> |
9+
<a class="exampleLink" id="strtokExampleLink" href="#">tokenize</a> |
10+
<a class="exampleLink" id="insSortExampleLink" href="#">insertion sort</a> |
11+
<a class="exampleLink" id="forElseLink" href="#">for-else</a> |
12+
<a class="exampleLink" id="rawInputExampleLink" href="#">user input</a>
13+
</p>
14+
15+
<p style="margin-top: 15px;">Math:
16+
<a class="exampleLink" id="factExampleLink" href="#">factorial</a> |
17+
<a class="exampleLink" id="fibonacciExampleLink" href="#">fibonacci</a> |
18+
<a class="exampleLink" id="memoFibExampleLink" href="#">memoized fibonacci</a> |
19+
<a class="exampleLink" id="newtonExampleLink" href="#">square root</a> |
20+
<a class="exampleLink" id="pwGcdLink" href="#">gcd</a> |
21+
<a class="exampleLink" id="towersOfHanoiLink" href="#">towers of hanoi</a>
22+
</p>
23+
24+
25+
<p style="margin-top: 15px;">Objects:
26+
27+
<a class="exampleLink" id="oop1ExampleLink" href="#">OOP 1</a> |
28+
<a class="exampleLink" id="oop2ExampleLink" href="#">OOP 2</a> |
29+
<a class="exampleLink" id="oopSmallExampleLink" href="#">OOP 3</a> |
30+
<a class="exampleLink" id="inheritanceExampleLink" href="#">inheritance</a>
31+
32+
</p>
33+
34+
<p style="margin-top: 15px;">Linked Lists:
35+
<a class="exampleLink" id="ll1Link" href="#">LL 1</a> |
36+
<a class="exampleLink" id="ll2Link" href="#">LL 2</a> |
37+
<a class="exampleLink" id="sumListLink" href="#">LL sum</a>
38+
</p>
39+
40+
<p style="margin-top: 15px;">Pointer Aliasing:<br/>
41+
<a class="exampleLink" id="aliasing1Link" href="#">aliasing1</a> |
42+
<a class="exampleLink" id="aliasing2Link" href="#">aliasing2</a> |
43+
<a class="exampleLink" id="aliasing3Link" href="#">aliasing3</a> |
44+
<a class="exampleLink" id="aliasing4Link" href="#">aliasing4</a> |
45+
<a class="exampleLink" id="aliasing5Link" href="#">aliasing5</a> |
46+
<a class="exampleLink" id="aliasing6Link" href="#">aliasing6</a> |
47+
<a class="exampleLink" id="aliasing7Link" href="#">aliasing7</a> |
48+
<a class="exampleLink" id="aliasing8Link" href="#">aliasing8</a> |
49+
<a class="exampleLink" id="pwSumListLink" href="#">sumList</a>
50+
</p>
51+
52+
<p style="margin-top: 15px;">Higher-Order Functions:<br/>
53+
54+
<a class="exampleLink" id="closure1Link" href="#">closure1</a> |
55+
<a class="exampleLink" id="closure2Link" href="#">closure2</a> |
56+
<a class="exampleLink" id="closure3Link" href="#">closure3</a> |
57+
<a class="exampleLink" id="closure4Link" href="#">closure4</a> |
58+
<a class="exampleLink" id="closure5Link" href="#">closure5</a> |
59+
<a class="exampleLink" id="mapExampleLink" href="#">list map</a> |
60+
<a class="exampleLink" id="sumExampleLink" href="#">summation</a> |
61+
<a class="exampleLink" id="lambdaParamLink" href="#">lambda param</a>
62+
63+
</p>
64+
65+
<p style="margin-top: 15px;">Advanced:<br/>
66+
<a class="exampleLink" id="listCompLink" href="#">list comp</a> |
67+
<a class="exampleLink" id="compsLink" href="#">list/set/dict comp</a> |
68+
<a class="exampleLink" id="decoratorsLink" href="#">decorator</a> |
69+
<a class="exampleLink" id="genPrimesLink" href="#">generator</a> |
70+
<a class="exampleLink" id="genExprLink" href="#">genexpr</a> |
71+
<a class="exampleLink" id="varargsLink" href="#">varargs</a> |
72+
<a class="exampleLink" id="pwTryFinallyLink" href="#">exception</a> |
73+
<a class="exampleLink" id="metaclassLink" href="#">metaclass</a>
74+
</p>
75+
76+
<p style="margin-top: 15px;">Python 3 only: <a class="exampleLink" id="tortureLink" href="#">student torture</a> |
77+
<a class="exampleLink" id="nonlocalLink" href="#">nonlocal</a>
78+
</p>`;
79+
80+
81+
export var javaExamples = `<p style="margin-top: 25px; font-weight: bold;">Java Examples</p>
82+
83+
<p>
84+
Basic:
85+
<a class="exampleLink" id="javaVarLink" href="#">Variables</a> |
86+
<a class="exampleLink" id="javaCFLink" href="#">ControlFlow</a> |
87+
<a class="exampleLink" id="javaSqrtLink" href="#">Sqrt</a> |
88+
<a class="exampleLink" id="javaExecLimitLink" href="#">ExecLimit</a> |
89+
<a class="exampleLink" id="javaStringsLink" href="#">Strings</a>
90+
</p>
91+
92+
<p>
93+
Methods:
94+
<a class="exampleLink" id="javaPassByValLink" href="#">PassByValue</a> |
95+
<a class="exampleLink" id="javaRecurLink" href="#">Recursion</a> |
96+
<a class="exampleLink" id="javaSOLink" href="#">StackOverflow</a>
97+
</p>
98+
99+
<p>
100+
OOP:
101+
<a class="exampleLink" id="javaRolexLink" href="#">Rolex</a> |
102+
<a class="exampleLink" id="javaPersonLink" href="#">Person</a> |
103+
<a class="exampleLink" id="javaComplexLink" href="#">Complex</a> |
104+
<a class="exampleLink" id="javaCastingLink" href="#">Casting</a>
105+
</p>
106+
107+
<p>
108+
Data structures:
109+
<a class="exampleLink" id="javaLLLink" href="#">LinkedList</a> |
110+
<a class="exampleLink" id="javaStackQueueLink" href="#">StackQueue</a> |
111+
<a class="exampleLink" id="javaPostfixLink" href="#">Postfix</a> |
112+
<a class="exampleLink" id="javaSTLink" href="#">SymbolTable</a>
113+
</p>
114+
115+
<p>
116+
Java features:
117+
<a class="exampleLink" id="javaToStringLink" href="#">ToString</a> |
118+
<a class="exampleLink" id="javaReflectLink" href="#">Reflect</a> |
119+
<a class="exampleLink" id="javaExceptionLink" href="#">Exception</a> |
120+
<a class="exampleLink" id="javaExceptionFlowLink" href="#">ExceptionFlow</a> |
121+
<a class="exampleLink" id="javaTwoClassesLink" href="#">TwoClasses</a>
122+
</p>
123+
124+
<p>
125+
Misc:
126+
<a class="exampleLink" id="javaForestLink" href="#">Forest</a> |
127+
<a class="exampleLink" id="javaKnapsackLink" href="#">Knapsack</a> |
128+
<a class="exampleLink" id="javaStaticInitLink" href="#">StaticInitializer</a> |
129+
<a class="exampleLink" id="javaSyntheticLink" href="#">Synthetic</a>
130+
</p>
131+
132+
<p style="margin-top: 5px;">(All Java examples created by <a href="https://github.com/daveagp">David Pritchard</a>)</p>`;
133+
134+
135+
export var jsExamples = `<p style="margin-top: 25px; font-weight: bold;">JavaScript Examples</p>
136+
137+
<p style="margin-top: 5px;">
138+
<a class="exampleLink" id="jsFactExLink" href="#">factorial</a> |
139+
<a class="exampleLink" id="jsDatatypesExLink" href="#">data types</a> |
140+
<a class="exampleLink" id="jsExceptionExLink" href="#">exception</a> |
141+
<a class="exampleLink" id="jsClosureExLink" href="#">closure</a> |
142+
<a class="exampleLink" id="jsShadowingExLink" href="#">shadowing</a> |
143+
<a class="exampleLink" id="jsConstructorExLink" href="#">constructor</a> |
144+
<a class="exampleLink" id="jsInhExLink" href="#">inheritance</a>
145+
</p>`;
146+
147+
148+
export var tsExamples = `<p style="margin-top: 25px; font-weight: bold;">TypeScript Examples</p>
149+
150+
<p style="margin-top: 5px;">
151+
<a class="exampleLink" id="tsHelloExLink" href="#">hello</a> |
152+
<a class="exampleLink" id="tsGreeterExLink" href="#">classes</a> |
153+
<a class="exampleLink" id="tsInheritanceExLink" href="#">inheritance</a> |
154+
<a class="exampleLink" id="tsGreeterGenericsExLink" href="#">generics</a>
155+
</p>`;
156+
157+
158+
export var rubyExamples = `<p style="margin-top: 25px; font-weight: bold;">Ruby Examples</p>
159+
160+
<p style="margin-top: 5px;">
161+
<a class="exampleLink" id="rubyContainersLink" href="#">Containers</a> |
162+
<a class="exampleLink" id="rubyGlobalsLink" href="#">Globals</a> |
163+
<a class="exampleLink" id="rubyConstantsLink" href="#">Constants</a> |
164+
<a class="exampleLink" id="rubyBlocksLink" href="#">Blocks</a> |
165+
<a class="exampleLink" id="rubyBlocksScopingLink" href="#">Block scoping</a> |
166+
<a class="exampleLink" id="rubyBlocksScoping3Link" href="#">More block scoping</a>
167+
<p/>
168+
<a class="exampleLink" id="rubyProcLink" href="#">Proc & Lambda</a> |
169+
<a class="exampleLink" id="rubyProcScopingLink" href="#">Proc scoping</a> |
170+
<a class="exampleLink" id="rubyProcReturnLink" href="#">Proc return</a> |
171+
<a class="exampleLink" id="rubyLambdaScopingLink" href="#">Lambda scoping</a> |
172+
<a class="exampleLink" id="rubyInheritanceLink" href="#">Inheritance</a> |
173+
<a class="exampleLink" id="rubySymbolsLink" href="#">Symbols</a>
174+
<p/>
175+
<a class="exampleLink" id="rubyPrivateProtectedLink" href="#">Protected & private</a> |
176+
<a class="exampleLink" id="rubyInstClassVarsComplexLink" href="#">Class & instance vars</a> |
177+
<a class="exampleLink" id="rubyToplevelLink" href="#">Toplevel defs</a> |
178+
<a class="exampleLink" id="rubyMegagreeterLink" href="#">Megagreeter</a>
179+
</p>`;
180+
181+
182+
export var cExamples = `<p style="margin-top: 25px; font-weight: bold;">C Examples</p>
183+
184+
<p style="margin-top: 5px;">
185+
<a class="exampleLink" id="cMengThesisLink" href="#">Thesis</a> |
186+
<a class="exampleLink" id="cGlobalsLink" href="#">Globals</a> |
187+
<a class="exampleLink" id="cStructLink" href="#">Structs</a> |
188+
<a class="exampleLink" id="cNestedStructLink" href="#">Nested structs</a> |
189+
<a class="exampleLink" id="cArrOverflowLink" href="#">Array overflow</a> |
190+
<a class="exampleLink" id="cArrParamLink" href="#">Array param</a>
191+
<p/>
192+
<a class="exampleLink" id="cStringRevLink" href="#">String reverse</a> |
193+
<a class="exampleLink" id="cPtrLevelsLink" href="#">Pointer levels</a> |
194+
<a class="exampleLink" id="cPtrChainLink" href="#">Pointer chain</a> |
195+
<a class="exampleLink" id="cPtrWildLink" href="#">Pointers wild</a> |
196+
<a class="exampleLink" id="cTypedefLink" href="#">Typedef</a>
197+
</p>`;
198+
199+
200+
export var cppExamples = `<p style="margin-top: 25px; font-weight: bold;">C++ Examples</p>
201+
202+
<p style="margin-top: 5px;">
203+
<a class="exampleLink" id="cppFirstLink" href="#">Basic</a> |
204+
<a class="exampleLink" id="cppPassRefLink" href="#">Pass by ref</a> |
205+
<a class="exampleLink" id="cppClassLink" href="#">Class</a> |
206+
<a class="exampleLink" id="cppClassPtrLink" href="#">Class pointer</a> |
207+
<a class="exampleLink" id="cppDateLink" href="#">Date class</a> |
208+
<a class="exampleLink" id="cppInheritLink" href="#">Inheritance</a> |
209+
<a class="exampleLink" id="cppVirtualLink" href="#">Virtual method</a>
210+
</p>`;

v5-unity/js/visualize.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import {OptFrontend} from './opt-frontend.ts';
66
import {OptFrontendSharedSessions,TogetherJS} from './opt-shared-sessions.ts';
77
import {assert,htmlspecialchars} from './pytutor.ts';
8-
import {OptTestcases, redSadFace, yellowHappyFace} from './opt-testcases.ts';
8+
import {OptTestcases,redSadFace,yellowHappyFace} from './opt-testcases.ts';
9+
import {pythonExamples,javaExamples,jsExamples,tsExamples,rubyExamples,cExamples,cppExamples} from './example-links.ts';
910

1011

1112
// for TypeScript
@@ -287,6 +288,15 @@ $(document).ready(function() {
287288
optFrontend = new OptFrontendWithTestcases();
288289
optFrontend.setSurveyHTML();
289290

291+
$("#exampleSnippets")
292+
.append(pythonExamples)
293+
.append(javaExamples)
294+
.append(jsExamples)
295+
.append(tsExamples)
296+
.append(rubyExamples)
297+
.append(cExamples)
298+
.append(cppExamples);
299+
290300
// canned examples
291301
$(".exampleLink").click(function() {
292302
var myId = $(this).attr('id');

0 commit comments

Comments
 (0)