Last active
September 16, 2022 21:00
-
-
Save danielmarquesr/ceefa761f42fc203a71421f913d9d82b to your computer and use it in GitHub Desktop.
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
(ns aula1.maps.exercicio | |
(:require [aula1.maps.data :as data])) | |
;; dado o mapa no namespace data.clj, escrever funcoes que: | |
;; altera a idade do cliente | |
;; remove o endereco do cliente | |
;; atualiza o valor de um item de compra | |
;; adicionar o vetor de compras no mapa do cliente | |
;; adiciona um novo item de compra | |
;; retorna o nome do cliente | |
(defn change-client-age | |
"Change client age." | |
[client new-age] | |
(assoc client :idade new-age)) | |
(defn remove-client-address | |
"Remove client address." | |
[client] | |
(dissoc client :endereco)) | |
(defn update-shop-item-value | |
"Update a shop item value." | |
[item change-value-function] | |
(update item :valor change-value-function)) | |
(defn add-shop-items-to-client | |
"Add to client map a shop items." | |
[client shops] | |
(assoc client :compras shops)) | |
(defn add-new-item-in-shops | |
"Add one item to the shopping items list." | |
[shop-items new-item] | |
(conj shop-items new-item)) | |
(defn get-client-name | |
"Get client name." | |
[client] | |
(:nome client)) | |
(comment | |
(change-client-age data/cliente 40) | |
(remove-client-address data/cliente) | |
(update-shop-item-value (data/compras 0) (fn [value] (* value 0.9))) | |
(add-shop-items-to-client data/cliente data/compras) | |
(add-new-item-in-shops data/compras {:item "celular" :valor 1200}) | |
(get-client-name data/cliente) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment