This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; slow because appending to a list means that | |
;; we have to traverse it over and over again | |
(defun my-rev-1 (lst) | |
(if (null lst) | |
'() | |
(append (my-rev-1 (cdr lst)) (list (car lst))))) | |
;; better because we use an empty list that we can | |
;; cons onto the front of (which is fast) | |
;; "labels" is a way to make a private recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head><title>Alignment Test</title> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" > | |
<style type="text/css"> | |
.threequarters { position: absolute; left: 75%; border: solid 1px; } | |
</style> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Container; //import java.awt.FlowLayout; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.awt.GridLayout; | |
import javax.swing.JApplet; | |
import javax.swing.JButton; | |
import javax.swing.JComboBox; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PrintArray | |
{ | |
public static void main(String[] args) | |
{ | |
// the basics of printing a 2d array | |
int[][] a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; | |
for (int i = 0; i < a.length; i++) { | |
int[] currRow = a[i]; | |
for (int j = 0; j < currRow.length; j++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
public class frame | |
{ | |
public static void main(String[] args) | |
{ | |
JFrame f = new JFrame(); | |
f.add(new JLabel("This is a window.")); | |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class e | |
{ | |
public static void main(String[] args) | |
{ | |
int iterations = Integer.parseInt(args[0]); | |
double result = 0; | |
for (int i = 0; i < iterations; i++) | |
result = result + 1.0 / fact(i); | |
System.out.println("e estimated with " + iterations + " terms: " + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<script type="text/javascript">alert('Hello');</script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class FooMap | |
{ | |
public static void main(String[] args) | |
{ | |
HashMap<String,String> data = | |
new HashMap<String,String>(); | |
String k1 = "A" + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/* a simple multiplication table */ | |
int main() | |
{ | |
char *cp; | |
char buffer[256]; | |
printf("Enter a number:\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn multtab [n] | |
(for [row (range n) col (range n)] | |
(* (inc row) (inc col)))) | |
;; reasonably nicely formatted | |
(defn main [n] | |
(let [width (int (Math/ceil (/ (Math/log (* n n)) (Math/log 10)))) | |
digit-str (str "%" (inc width) "d")] | |
(doseq [row (partition n (multtab n))] | |
(let [formatted-row (map #(format digit-str %) row)] |
OlderNewer