Skip to content

Instantly share code, notes, and snippets.

View bhargavg's full-sized avatar

Bhargav Gurlanka bhargavg

View GitHub Profile
_ _
| |__ | |__ __ _ _ __ __ _ __ ___ ____ _
| '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` |
| |_) | | | | (_| | | | (_| | (_| |\ V / (_| |
|_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, |
|___/ |___/
Just a dummy text file to have a proper titles for gists 😒
_ _
| |__ | |__ __ _ _ __ __ _ __ ___ ____ _
| '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` |
| |_) | | | | (_| | | | (_| | (_| |\ V / (_| |
|_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, |
|___/ |___/
Just a dummy text file to have a proper titles for gists 😒
#!/bin/bash
#
# Faster toolchain build: skips as much as possible.
#
# To use this toolchain from the command line:"
# export TOOLCHAINS=$(whoami)
#
# we build to the same prefix every time (instead of building
# to a versioned prefix) because every time the prefix changes
# *everything* rebuilds.
@bhargavg
bhargavg / main.swift
Created September 25, 2016 07:08
Functional Integer List in Swift - Inspired by Programming Languages Lecture by Dan Grossman (Coursera)
indirect enum IntList {
case empty
case cons(Int, IntList)
}
extension IntList {
static func append(_ xs: IntList, _ ys: IntList) -> IntList{
switch xs {
case .empty: return ys;
case let .cons(head, tail): return .cons(head, append(tail, ys));
(* Problem: Write a function that returns true
* when invoked with list of alternate 1's and 2's
*
* Example:
* matcher [1,2,1,2]
* matcher [1,2,1]
* matcher [1,2]
* matcher [1]
*
* all of the above should return true
_ _
| |__ | |__ __ _ _ __ __ _ __ ___ ____ _
| '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` |
| |_) | | | | (_| | | | (_| | (_| |\ V / (_| |
|_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, |
|___/ |___/
Just a dummy text file to have a proper titles for gists 😒
@bhargavg
bhargavg / LaunchProcessArgs.swift
Last active April 21, 2022 17:51
An interactive process
import Foundation
struct LaunchProcessArgs: OptionSet {
let rawValue: Int
static let attachStdIn = LaunchProcessArgs(rawValue: 1 << 0)
static let attachStdOut = LaunchProcessArgs(rawValue: 1 << 1)
static let attachStdErr = LaunchProcessArgs(rawValue: 1 << 2)
static let interactive: LaunchProcessArgs = [.attachStdIn, .attachStdOut, .attachStdErr]