<commit_before>(ns clojush.instructions.return
  (:use [clojush pushstate util]))

(defn returner
  "Returns a function that takes a state and moves the top literal
   from the appropriate stack to the return stack."
  [type]
  (fn [state]
    (if (empty? (type state))
      state
      (let [item (top-item type state)]
        (push-item {:type type :item item} :return (pop-item type state))))))

(define-registered return_fromexec (with-meta (returner :exec) {:stack-types [:environment :exec] :parentheses 1}))
(define-registered return_fromcode (with-meta (returner :code) {:stack-types [:environment :code]}))
(define-registered return_frominteger (with-meta (returner :integer) {:stack-types [:environment :integer]}))
(define-registered return_fromfloat (with-meta (returner :float) {:stack-types [:environment :float]}))
(define-registered return_fromboolean (with-meta (returner :boolean) {:stack-types [:environment :boolean]}))
(define-registered return_fromzip (with-meta (returner :zip) {:stack-types [:environment :zip]}))
(define-registered return_fromstring (with-meta (returner :string) {:stack-types [:environment :string]}))
(define-registered return_fromchar (with-meta (returner :char) {:stack-types [:environment :char]}))
(define-registered return_fromgenome (with-meta (returner :genome) {:stack-types [:environment :genome]}))

(define-registered
  return_exec_pop
  ^{:stack-types [:environment :exec]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :exec :popper true}) (:return state)))))

(define-registered
  return_code_pop
  ^{:stack-types [:environment :code]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :code :popper true}) (:return state)))))

(define-registered
  return_integer_pop
  ^{:stack-types [:environment :integer]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :integer :popper true}) (:return state)))))

(define-registered
  return_float_pop
  ^{:stack-types [:environment :float]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :float :popper true}) (:return state)))))

(define-registered
  return_boolean_pop
  ^{:stack-types [:environment :boolean]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :boolean :popper true}) (:return state)))))

(define-registered
  return_zip_pop
  ^{:stack-types [:environment :zip]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :zip :popper true}) (:return state)))))

(define-registered
  return_string_pop
  ^{:stack-types [:environment :string]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :string :popper true}) (:return state)))))

(define-registered
  return_char_pop
  ^{:stack-types [:environment :char]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :char :popper true})) (:return state)))))

; Immediately copies the current tagspace to the environment on the top
; of the :environment stack.
(define-registered
  return_tagspace
  ^{:stack-types [:environment]}
  (fn [state]
    (if (empty? (:environment state))
      state
      (let [top-env (top-item :environment state)<commit_msg>Add return_genome_pop, fix parenthesis error<commit_after>(ns clojush.instructions.return
  (:use [clojush pushstate util]))

(defn returner
  "Returns a function that takes a state and moves the top literal
   from the appropriate stack to the return stack."
  [type]
  (fn [state]
    (if (empty? (type state))
      state
      (let [item (top-item type state)]
        (push-item {:type type :item item} :return (pop-item type state))))))

(define-registered return_fromexec (with-meta (returner :exec) {:stack-types [:environment :exec] :parentheses 1}))
(define-registered return_fromcode (with-meta (returner :code) {:stack-types [:environment :code]}))
(define-registered return_frominteger (with-meta (returner :integer) {:stack-types [:environment :integer]}))
(define-registered return_fromfloat (with-meta (returner :float) {:stack-types [:environment :float]}))
(define-registered return_fromboolean (with-meta (returner :boolean) {:stack-types [:environment :boolean]}))
(define-registered return_fromzip (with-meta (returner :zip) {:stack-types [:environment :zip]}))
(define-registered return_fromstring (with-meta (returner :string) {:stack-types [:environment :string]}))
(define-registered return_fromchar (with-meta (returner :char) {:stack-types [:environment :char]}))
(define-registered return_fromgenome (with-meta (returner :genome) {:stack-types [:environment :genome]}))

(define-registered
  return_exec_pop
  ^{:stack-types [:environment :exec]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :exec :popper true}) (:return state)))))

(define-registered
  return_code_pop
  ^{:stack-types [:environment :code]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :code :popper true}) (:return state)))))

(define-registered
  return_integer_pop
  ^{:stack-types [:environment :integer]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :integer :popper true}) (:return state)))))

(define-registered
  return_float_pop
  ^{:stack-types [:environment :float]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :float :popper true}) (:return state)))))

(define-registered
  return_boolean_pop
  ^{:stack-types [:environment :boolean]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :boolean :popper true}) (:return state)))))

(define-registered
  return_zip_pop
  ^{:stack-types [:environment :zip]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :zip :popper true}) (:return state)))))

(define-registered
  return_string_pop
  ^{:stack-types [:environment :string]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :string :popper true}) (:return state)))))

(define-registered
  return_char_pop
  ^{:stack-types [:environment :char]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :char :popper true}) (:return state)))))

(define-registered
  return_genome_pop
  ^{:stack-types [:environment :genome]}
  (fn [state]
    (assoc state :return (list-concat (list {:type :genome :popper true}) (:return state)))))

; Immediately copies the current tagspace to the environment on the top
; of the :environment stack.
(define-registered
  return_tagspace
  ^{:stack-types [:environment]}
  (fn [state]
    (if (empty? (:environment state))
      state
      (let [top-env (top-item :environment state)
{'fraction_non_alphanumeric': 0.155668358714044, 'fraction_numerical': 0.00030764497769573913, 'mean_word_length': 5.151371807000946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3086720', 'n_tokens_mistral': 2123, 'n_tokens_neox': 2008, 'n_words': 619}