Skip to content

Instantly share code, notes, and snippets.

View sausheong's full-sized avatar

Chang Sau Sheong sausheong

View GitHub Profile
  1. Callout: Use python directive to call Python statements. Enclose the Python statement in square brackets []. Example: python[print('hello world')] will call the Python statement print('hello world').

PromptScript is a pseudolanguage designed to structure and clarify interactions with AI models like GPT-4. It allows users to express complex tasks, rules, and heuristics, helping the AI understand the tasks more accurately.

  1. Directives: These set the context for an instruction. Begin a directive with #. The following directives can be used: #story, #technical, #informal, #formal. Use #heuristic when defining heuristics. Example:

    #technical 
    explain {quantum physics}
    
  2. Action Words: Standard English verbs that define the task for the AI. These include but are not limited to describe, explain, list, summarize. Example: describe {the Eiffel Tower}

func (h *Heap) rearrange(i int) {
...
if left < size && h.elements[left-1] > h.elements[largest] {
largest = left
}
...
}
func FuzzHeap(f *testing.F) {
var h *Heap = &Heap{}
h.elements = []int{452, 23, 6515, 55, 313, 6}
h.Build()
testCases := []int{51, 634, 9, 8941, 354}
for _, tc := range testCases {
f.Add(tc)
}
func TestHeap(t *testing.T) {
var h *Heap = &Heap{}
h.elements = []int{452, 23, 6515, 55, 313, 6}
h.Build()
testCases := []int{51, 634, 9, 8941, 354}
for _, tc := range testCases {
h.Push(tc)
// make a copy of the elements in the slice and sort it in descending order
elements := make([]int, len(h.elements))
type Heap struct {
elements []int
}
func (h *Heap) Push(ele int) {
h.elements = append(h.elements, ele)
i := len(h.elements) - 1
for ; h.elements[i] > h.elements[parent(i)]; i = parent(i) {
h.swap(i, parent(i))
}
func TestTSetInt(t *testing.T) {
set := NewTSet[int]()
set.Add(100)
set.Add(200)
set.Add(300)
set.Add(400)
if !set.Has(400) {
t.Error("set doesn't have 400")
}
func TestTSet(t *testing.T) {
set := NewTSet[string]()
set.Add("the")
set.Add("quick")
set.Add("brown")
set.Add("fox")
set.Add("the")
if !set.Has("quick") {
t.Error("set doesn't have quick")
@sausheong
sausheong / tset.go
Created May 16, 2022 06:46
generics
type TSet[K comparable, V int] struct {
items map[K]V
}
func NewTSet[K comparable, V int]() TSet[K, V] {
return TSet[K, V]{items: make(map[K]V)}
}
func (s *TSet[K, V]) Add(item K) {
s.items[item] = 1
func TestSet(t *testing.T) {
set := NewSet()
set.Add("the")
set.Add("quick")
set.Add("brown")
set.Add("fox")
set.Add("the")
if !set.Has("quick") {