# Extracting a pure function — prompt for Gemma

Separate computation from input/output while preserving side-effect order and current behavior.

Canonical URL: https://boswidget.ru/en/extracting-a-pure-function-prompt-for-gemma/

Model: Gemma

Category: Code

Tags: refactoring, pure function, dependencies

![Extracting a pure function](https://boswidget.ru/assets/images/text-preview-gm-vydelenie-chistoj-funkcii-1200.a5e1990e1120.webp)

Extracting a pure function

## Prompt

Refactor this code: {code}. Behavior and constraints: {rules}. Separate pure computation from reads, writes and network actions. Pass dependencies explicitly; do not add a framework or unnecessary class hierarchy. Show the original input-output mapping, new code and locations of preserved side effects. Identify operations whose order must not change. Give equivalence checks for three inputs. Do not claim the code has been run.

## Template fields

- `{code}` — Code. Example input: Small excerpt mixing computations with input/output
- `{rules}` — Behavior. Example input: Language, required effects and known edge cases

## Launch

[Open Gemma in YesAI](https://yesai.su/en/gemma)
