- Callout: Use
python
directive to call Python statements. Enclose the Python statement in square brackets[]
. Example:python[print('hello world')]
will call the Python statementprint('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.
-
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}
-
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}
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
func (h *Heap) rearrange(i int) { | |
... | |
if left < size && h.elements[left-1] > h.elements[largest] { | |
largest = left | |
} | |
... | |
} |
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
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) | |
} |
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
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)) |
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
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)) | |
} |
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
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") | |
} |
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
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") |
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
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 |
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
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") { |
NewerOlder