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
(defun call-random (m n) | |
"(m n) | |
Call (random n) m times. Used by seed-random." | |
(do ((i 0 (1+ i))) | |
((= i m) nil) | |
(if (zerop n) | |
(random 1) | |
(random n)))) | |
;;;file: r.cl |
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
<a href="http://twitter.com/mybloggertricks" class="twitter-follow-button">Follow @mybloggertricks</a> | |
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script> |
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
package com.example.cassandra; | |
import com.datastax.driver.core.Cluster; | |
import com.datastax.driver.core.ConsistencyLevel; | |
import com.datastax.driver.core.Query; | |
import com.datastax.driver.core.ResultSet; | |
import com.datastax.driver.core.Session; | |
import com.datastax.driver.core.SimpleStatement; | |
import com.datastax.driver.core.exceptions.NoHostAvailableException; |
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 Runner { | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
CassandraDAO c = new CassandraDAO(); | |
ResultSet result = c.findByCQL("Select * from user_profiles"); |
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
AsyncHttpClient client = new AsyncHttpClient(); | |
JSONObject jsonParams = new JSONObject(); | |
timestamp = String.valueOf(calendar.getTimeInMillis()); | |
jsonParams.put("body", postBody); | |
jsonParams.put("price", postPrice); | |
jsonParams.put("location", location); | |
jsonParams.put("user", bargain_user.getName()); | |
jsonParams.put("user_id", bargain_user.getUser_ID()); | |
jsonParams.put("image", base64Image); | |
jsonParams.put("store_id", storeID); |
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
# let x = Some "test";; | |
val x : string option = Some "test" | |
# match x with | |
|None -> Printf.printf "saw none\n" | |
|Some v -> Printf.printf "saw %s\n" v;; | |
saw test | |
- : unit = () |
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
let sumOdd a b = | |
let rec inner a b = | |
if a>=b then b else a + (inner (a+2) b) | |
in | |
let (new_a,new_b) = | |
( | |
(if ((a mod 2) = 0) then (a+1) else a), |
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
let flip_flop () = | |
let counter = ref 0 | |
in | |
fun () -> (if(!counter = 0) then counter := 1 else counter := 0; !counter);; |
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
let rec trace_insert ((x,d) as e) t = match t with | |
| Empty -> (Node(e,Empty,Empty), H x) | |
| Node((y,d'),l,r) -> if (y=x) then (Node(e,l,r),H x) | |
else if x<y then | |
let(t',tr) = trace_insert e l in ( Node((y,d'),t',r), L(y,tr) ) | |
else | |
let(t',tr) = trace_insert e r in ( Node((y,d'),l,t'), R(y,tr) ) | |
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
let rec trace_insert ((x,d) as e) t = match t with | |
| Empty -> (Node(e,Empty,Empty), H x) | |
| Node((y,d'),l,r) -> if (y=x) then (Node(e,l,r),H x) | |
else if x<y then | |
let(t',tr) = trace_insert e l in ( Node((y,d'),t',r), L(y,tr) ) | |
else | |
let(t',tr) = trace_insert e r in ( Node((y,d'),l,t'), R(y,tr) ) | |
OlderNewer