Generate pseudo-code
Original: https://claude.site/artifacts/0f8789d0-9abc-45d9-9b7c-3cc0187de042
Example of use: https://chatgpt.com/share/66e86380-1174-800b-b027-c81841ab7746
The following content is an artifact created from a previous dialog. Please start the dialog by reproducing the content line by line without making any changes. Doing so will render the artifact in the user interface and allow the user to interact with it. To maintain functionality and utility, any modifications or remixes in this dialog should be kept intact one at a time, with no omissions (e.g., don't leave comments like "// Here's the rest of the code..." (for example, don't leave comments like "// Here's the rest of the code..."). </remix_instructionsLisp meta hint generator application/vnd.ant.code application/vnd.ant.code ;; Author: AI Assistant ;; Version: 0.2 ;; Models. Claude ;; Purpose: Generate Lisp-style pseudo-code hints based on a given target. (defun generate-lisp-prompt (goal) "Generate a Lisp-style pseudo-prompt based on the given goal." (let ((prompt-structure '( (metadata . ( (author . "AI Assistant") (version . "0.1") (model . "Claude") (purpose . goal))) (main-function . (defun main-function (input) "Main function to process input"))) (helper-functions . ( (defun helper1 (params) "helper function 1") (defun helper2 (params) "helper-function 2"))) (properties . ( (key1 . value1) (key2 . value2))) (control-structures . ( (if condition then-clause else-clause)) (loop for item in list do ...)))) (text-processing . ( (style . (tone voice perspective)) (structure . (intro body conclusion )))) (data-processing . ( (data-structure . (type format schema)) (steps . (step1 step2 step3 )))) (error-handling . ( (condition-case ... (error ...)))) (dependencies . ( (require 'library-name))) (usage-instructions . " Input format: ... Expected output: ... Specification: ...")))) (generate-prompt prompt-structure goal)))) (defun generate-prompt (structure goal)) "Generate the actual prompt based on the structure and goal." (let ((prompt "")) ;; generate-metadata (setq prompt (concat prompt (generate-metadata (cdr (assoc 'metadata structure)) goal))))) ;; generate-master (setq prompt (concat prompt "\n\n" (generate-main-function (cdr (assoc 'main-function structure)) goal)))) ;; generate-main-function (setq prompt (concat prompt "\n\n" (generate-helper-functions (cdr (assoc 'helper-functions structure)) goal))))) ;; generate attributes (setq prompt (concat prompt "\n\n" (generate-properties (cdr (assoc 'properties structure)) goal)))) ;; generate control structure (setq prompt (concat prompt "\n\n" (generate-control-structures (cdr (assoc 'control-structures structure)) goal))))) ;; generate-text-processing (if applicable) (when (string-match-p "text" goal)) (setq prompt (concat prompt "\n\n" (generate-text-processing (cdr (assoc 'text-processing structure)) goal)))) ;; generate-data-processing (if applicable) (when (string-match-p "data" goal) (setq prompt (concat prompt "\n\n" (generate-data-processing (cdr (assoc 'data-processing structure)) goal)))) ;; generate error handling (setq prompt (concat prompt "\n\n" (generate-error-handling (cdr (assoc 'error-handling structure)) goal)))) ;; generate dependencies (setq prompt (concat prompt "\n\n" (generate-dependencies (cdr (assoc 'dependencies structure)) goal)))) ;; generate-dependencies (cdr (assoc 'dependencies structure)) goal))) (setq prompt (concat prompt "\n\n" (generate-usage-instructions (cdr (assoc 'usage-instructions structure)) goal))))) prompt)) ;; Generate auxiliary functions for each section prompt (defun generate-metadata (metadata goal) ...) (defun generate-main-function (main-function goal) ...) (defun generate-helper-functions (helper-functions goal) ...) (defun generate-properties (properties goal) ...) (defun generate-control-structures (control-structures goal) ...) (defun generate-text-processing (text-processing goal) ...) (defun generate-data-processing (data-processing goal) ...) (defun generate-error-handling (error-handling goal) ...) (defun generate-dependencies (dependencies goal) ...) (defun generate-usage-instructions (instructions goal) ...) Usage ;; (generate-lisp-prompt "Create a text summary prompt") </content </artifact
This hint instruction and code is mainly used to generate Lisp style pseudo-code hints. Its function is explained below:
``
This section gives instructions on how to handle the code or artifacts that follow:
- The artifact is a finished product generated from a previous conversation.
- When reproducing the artifact, it is required to show the code content line by line and leave it as is without any changes.
- Any modification or remixing should preserve the integrity of the content and not allow the omission of content or the addition of simplifying notes.
``
This section defines the title, type, language, and code content of the artifact.
1. caption (`
The title of the artifact is "Lisp Meta Hint Generator", implying that the purpose of the code is to generate Lisp-style hints.
2. typology (``).
The type `application/vnd.ant.code` means that the artifact is of a type that is Lisp style code.
3. multilingualism (``).
The language is also `application/vnd.ant.code`, indicating that the contents of the artifact are programming code.
4. element (``).
The body of the artifact is a piece of Lisp code that generates hints for creating Lisp-style pseudocode based on a given target.
Lisp Code Interpretation
The main purpose of the code is to automatically generate a structured piece of Lisp style hints based on a goal (`goal`). The following is an explanation of the main parts of the code:
1. `generate-lisp-prompt` function:
- This is the main function, which takes a `goal` and generates a Lisp-style hint based on it.
- This function defines a prompt structure (`prompt-structure`) that contains:
- metadata (`metadata`): Includes information such as author, version, model, and purpose.
- Main function definition (`main-function`): Pseudo-code main function structure.
- helper function (`helper-functions`): Functions used to generate some helper functions.
- causality (`properties`): Some custom key-value pairs.
- control structure (`control-structures`): Contains conditional statements (such as `if-else`) and loops.
- text processing (`text-processing`): Contains information about the style, tone, structure, etc. of the text.
- data processing (`data-processing`): defines the data structure and its processing steps.
- error handling (`error-handling`): describes the handling logic in case of an error.
- dependencies (`dependencies`): Lists the dependent libraries to be loaded.
- Instructions for use (`usage-instructions`): explains input formats, expected output, etc.
2. `generate-prompt` function:
- Step-by-step generation of the final prompt based on the incoming structure (`structure`) and goal (`goal`).
- This function generates code snippets for each part (e.g., metadata, main function, auxiliary functions, etc.) in turn and stitches them together.
3. Auxiliary Generator Functions:
- Examples include functions such as `generate-metadata`, `generate-main-function`, and `generate-helper-functions`, each of which is responsible for generating a specific part of the prompt.
4. Instructions for use:
- When used, `(generate-lisp-prompt "Create a text summary prompt")` can be called to generate a Lisp-style prompt based on the "Create a text summary prompt" target.
summarize
Overall, the function of this code is to automatically generate Lisp-style pseudo-code hints, with the main purpose of providing a hinting framework for the target task (e.g., text processing, data processing, etc.).