Skip to content

Instantly share code, notes, and snippets.

View tylerlrhodes's full-sized avatar
🍕

Tyler Rhodes tylerlrhodes

🍕
View GitHub Profile

Keybase proof

I hereby claim:

  • I am tylerlrhodes on github.
  • I am tylerlrhodes (https://keybase.io/tylerlrhodes) on keybase.
  • I have a public key ASBiCF6r0YISZPg0VFNGwull09dmM3uR0XhkUZY38FJ2_wo

To claim this, I am signing this object:

1) Start the debugee program (HelloWorld in this example)
in one command window:
% java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=4571 HelloWorld
2) In another window, attach your debugger (jdb in this example)
to the debugee via a socket:
% jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=4571
#lang sicp
(define (identity x) x)
(define (enumerate-interval low high)
(if (> low high)
nil
(cons low (enumerate-interval (+ low 1) high))))
(define (append list1 list2)
@tylerlrhodes
tylerlrhodes / SelectManyExample.cs
Created September 15, 2018 17:03
Demo of SelectMany function
using System;
using System.Collections.Generic;
using System.Linq;
namespace SelectManyExample
{
public class BookCase
{
public List<string> Books { get; set; } = new List<string>();
}
#lang sicp
(define (append0 list1 list2)
(if (null? list1)
list2
(cons (car list1)
(append0 (cdr list1) list2))))
(append0 '(1 2 3) '(4 5 6))
; {1 2 3 4 5 6}
@tylerlrhodes
tylerlrhodes / higher-order-procedure.scm
Created July 8, 2018 18:40
Scheme demo of higher order procedure
(define (sum term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (+ result (term a)))))
(iter a 0))
(define (identity x) x)
(define (inc x) (+ 1 x))
@tylerlrhodes
tylerlrhodes / functionClosures.go
Created July 8, 2018 18:36
Function Closures example in Go, from Tour of Go
package main
import "fmt"
func adder() func(int) int {
sum := 0
return func(x int) int {
sum += x
return sum
}
@tylerlrhodes
tylerlrhodes / CQsortDemo.cpp
Created July 8, 2018 18:11
QSort demo in C for Higher Order Function
#include <stdio.h>
#include <stdlib.h>
void print_array(int* array, size_t size)
{
for (unsigned i = 0; i < size; ++i)
{
printf("%d\n", *array++);
}
@tylerlrhodes
tylerlrhodes / HigherOrderDemo.cs
Created July 8, 2018 17:51
Demo of higher order function in c#
using System;
using System.Collections.Generic;
namespace HigherOrderProceduresDemo
{
class Program
{
static void Map(IEnumerable<int> list, Action<int> fn)
{
foreach (var item in list)
@tylerlrhodes
tylerlrhodes / sicp1.6.scm
Created June 17, 2018 16:35
sicp1.6 Applicative Order Evaluation and an infinite loop
#lang sicp
;; Applicative order evaluation
(define (new-if predicate then-clause else-clause)
(cond (predicate then-clause)
(else else-clause)))
(define (sqrt-iter guess x)
(display guess)