{"id":255480,"date":"2015-04-17T22:25:02","date_gmt":"2015-04-17T18:25:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=255480"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=255480","title":{"rendered":"\u0421\u0443\u043f\u0435\u0440 \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a \u043d\u0430 ClojureCLR"},"content":{"rendered":"<p> \t\t\t\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 Clojure \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0430 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 STM (The software transactional memory system). \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0420\u0438\u0447 \u0425\u0438\u043a\u043a\u0438 (\u0431\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u0440 Clojure) \u0438 \u0414\u044d\u0432\u0438\u0434 \u041c\u0438\u043b\u043b\u0435\u0440 (\u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e Clojure \u043f\u043e\u0434 .Net) \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u00abants\u00bb, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u0442 \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a. \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0442\u0430\u043c \u0436\u0438\u0432\u0435\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u041c\u0443\u0440\u0430\u0432\u044c\u0438 \u0431\u0435\u0433\u0430\u044e\u0442 \u043f\u043e \u043a\u043b\u0435\u0442\u043a\u0430\u043c \u043e\u0431\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f, \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u0435\u0434\u0443, \u043d\u043e\u0441\u044f\u0442 \u0435\u0435 \u0432 \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a \u0438 \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0432\u043e\u0438\u0445 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0439 \u0441 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 \u044f \u0438 \u0445\u043e\u0447\u0443 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043d\u0430 \u043e\u0431\u0449\u0435\u0435 \u043e\u0431\u043e\u0437\u0440\u0435\u043d\u0438\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 Clojure \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 .Net.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u043f\u0435\u0440\u0432\u0430 \u0441\u0441\u044b\u043b\u043a\u0438:<\/p>\n<p>  <a href=\"https:\/\/github.com\/kemerovo-man\/super-ants-clojure-clr\">github.com\/kemerovo-man\/super-ants-clojure-clr<\/a><br \/>  <a href=\"https:\/\/youtu.be\/xZ9AGQ3L-EI\">youtu.be\/xZ9AGQ3L-EI<\/a><br \/>  <a href=\"http:\/\/sourceforge.net\/projects\/clojureclr\/files\/\">sourceforge.net\/projects\/clojureclr\/files<\/a><br \/>  <a href=\"https:\/\/github.com\/clojure\/clojure-clr\/blob\/master\/Clojure\/Clojure.Source\/clojure\/samples\/ants.clj\">github.com\/clojure\/clojure-clr\/blob\/master\/Clojure\/Clojure.Source\/clojure\/samples\/ants.clj<\/a><\/p>\n<p>  \u0427\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043c\u043d\u043e\u044e.<br \/>  1. <b>\u0413\u0440\u0430\u0444\u0438\u043a\u0430<\/b>. \u0412 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u2014 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0442\u043e\u0447\u043a\u0430. \u0423 \u043c\u0435\u043d\u044f \u043d\u0430\u0441\u0435\u043a\u043e\u043c\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u044b \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0435\u0435.<br \/>  2. <b>\u041d\u043e\u0432\u044b\u0435 \u0433\u0435\u0440\u043e\u0438<\/b>. \u041a\u0440\u043e\u043c\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0435\u0432 \u0443 \u043c\u0435\u043d\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0442\u043b\u0438 \u0438 \u0431\u043e\u0436\u044c\u0438 \u043a\u043e\u0440\u043e\u0432\u043a\u0438.<br \/>  3. <b>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0433\u0435\u0440\u043e\u0435\u0432<\/b>. \u0420\u0430\u0441\u0442\u0435\u0442 \u0442\u0440\u0430\u0432\u0430, \u0442\u043b\u044f \u0435\u0441\u0442 \u0442\u0440\u0430\u0432\u0443, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0441\u0430\u0445\u0430\u0440 \u0438 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u044f\u0439\u0446\u0430 (\u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f). \u0411\u043e\u0436\u044c\u0438 \u043a\u043e\u0440\u043e\u0432\u043a\u0438 \u0435\u0434\u044f\u0442 \u0442\u043b\u044e \u0438 \u044f\u0439\u0446\u0430. \u041c\u0443\u0440\u0430\u0432\u044c\u0438 \u043e\u0431\u0445\u043e\u0434\u044f\u0442 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u043f\u0443\u0442\u0438. (\u0415\u0449\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0442\u0430\u0441\u043a\u0430\u0442\u044c \u0442\u043b\u044e \u043d\u0430 \u0442\u0440\u0430\u0432\u0443 \u0438 \u043c\u0435\u0448\u0430\u0442\u044c \u0431\u043e\u0436\u044c\u0438\u043c \u043a\u043e\u0440\u043e\u0432\u043a\u0430\u043c \u043f\u043e\u0436\u0438\u0440\u0430\u0442\u044c \u0442\u043b\u044e, \u043d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e.)<br \/>  3. <b>\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/b>. \u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u0443\u0440\u0430\u0432\u044c\u0435\u0432 \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043b\u043e\u0441\u044c, \u043e\u043d\u0438 \u0441\u0442\u0430\u043b\u0438 \u0443\u043c\u043d\u0435\u0435, \u0447\u0435\u043c \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0433\u0435\u0440\u043e\u0435\u0432.<br \/>  4. <b>\u0413\u0440\u0430\u0444\u0438\u043a\u0438<\/b>. \u0412\u0438\u0434\u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u0445. \u0420\u043e\u0441\u0442 \u0442\u0440\u0430\u0432\u044b, \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0442\u043b\u0438, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0430\u0445\u0430\u0440\u0430 \u0432 \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a\u0435 \u0438 \u0432 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435.<br \/>  5. <b>\u041f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0430\u044f \u043b\u0443\u043f\u0430<\/b> \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u0438. \u041f\u0440\u0430\u0432\u0430\u044f \u043a\u043d\u043e\u043f\u043a\u0430 \u043c\u044b\u0448\u043a\u0438.<br \/>  6. <b>\u041c\u044b\u0448\u043a\u0430<\/b>. \u041f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u043d\u0430 \u043a\u043b\u0435\u0442\u043a\u0443 \u043f\u043e\u043b\u044f \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f\u0441\u044f \u0432 \u043a\u043b\u0435\u0442\u043a\u0435. \u041a\u043e\u043b\u0435\u0441\u0438\u043a\u043e\u043c \u043c\u044b\u0448\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u0435\u043a\u043e\u043c\u044b\u0445.<\/p>\n<p>  \u041c\u0435\u043d\u044f\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u044d\u0442\u043e\u0439 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0427\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0441\u0442\u0435\u0442 \u0442\u0440\u0430\u0432\u0430, \u0442\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u0442\u043b\u044f \u0438 \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u0445\u0430\u0440\u0430 \u043d\u0430 \u043f\u043e\u043b\u0435. \u0422\u0440\u0430\u0432\u0430 \u043d\u0435 \u0440\u0430\u0441\u0442\u0435\u0442 \u043d\u0430 \u0441\u0430\u0445\u0430\u0440\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0440\u043d\u0430\u044f \u0436\u0438\u0437\u043d\u0435\u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0442\u043b\u0438 \u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u043e\u0441\u0442\u0435 \u0442\u0440\u0430\u0432\u044b. \u0420\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u0441\u0435\u043a\u043e\u043c\u044b\u0445 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 (\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043b\u0438, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u0436\u044c\u0438\u0445 \u043a\u043e\u0440\u043e\u0432\u043e\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u0435\u0432) \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043d\u043e\u0432\u0443\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443.<\/p>\n<p>  \u041a\u0430\u0436\u0434\u043e\u0435 \u043d\u0430\u0441\u0435\u043a\u043e\u043c\u043e\u0435 \u0432\u0438\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u043b\u0435\u0442\u043a\u0438: \u0442\u0443 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u0438 \u0442\u0440\u0438 \u043a\u043b\u0435\u0442\u043a\u0438 \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0431\u043e\u0439, \u043f\u043e \u043d\u0438\u043c \u0438 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<br \/>  \u041c\u0443\u0440\u0430\u0432\u044c\u0438 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u044e\u0442 \u043d\u0430 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u043e\u0432\u044b\u0439 \u0441\u043b\u0435\u0434. \u0414\u043b\u044f \u043d\u0438\u0445 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u0442\u0435\u0440\u044f\u0442\u044c \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a, \u0438\u043d\u0430\u0447\u0435 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0431\u0435\u0433\u0430\u0442\u044c \u0441 \u0435\u0434\u043e\u0439 \u00ab\u0432 \u0437\u0443\u0431\u0430\u0445\u00bb, \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u044f, \u043a\u0443\u0434\u0430 \u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c. \u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0438\u0447, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0444\u0435\u0440\u043e\u043c\u043e\u043d\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043c\u043e\u0433\u043b\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0433\u0434\u0435 \u0435\u0434\u0430, \u0433\u0434\u0435 \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a.<\/p>\n<p>  \u0411\u043b\u0438\u0436\u0435 \u0432 \u043a\u043e\u0434\u0443. \u041d\u043e \u043d\u0430\u0447\u043d\u0443 \u0438\u0437\u0434\u0430\u043b\u0435\u043a\u0430.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u043c\u0438 \u0432 Clojure, \u043a\u0430\u043a atom, agent \u0438 ref. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445. \u041a\u043e\u0434 \u043d\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0430 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430. Atom, agent \u0438 ref \u2014 \u044d\u0442\u043e \u0442\u0440\u0438 \u0442\u0438\u043f\u0430 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430.<\/p>\n<pre><code class=\"lisp\">(def atom1 (atom 0)) (def agent1 (agent 0)) (def ref1 (ref 0)) <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 atom1, agent1 \u0438 ref1. \u041d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443 \u0432\u0441\u0435\u0445 \u0440\u0430\u0432\u043d\u043e 0.<\/p>\n<pre><code class=\"lisp\">(swap! atom1 inc) (prn @atom1) ;-&gt;1  (send agent1 inc) (prn @agent1) ;-&gt;1  (dosync      (alter ref1 inc)) (prn @ref1) ;-&gt;1 <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 atom1, agent1 \u0438 ref1 \u0444\u0443\u043d\u043a\u0446\u0438\u044e inc \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 1 \u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0435\u0437\u0434\u0435 \u0441\u0442\u0430\u043b\u0438 \u0440\u0430\u0432\u043d\u044b 1.<\/p>\n<pre><code class=\"lisp\">(reset! atom1 0) (send agent1 (fn [_] 0)) (dosync  \t(ref-set ref1 0)) <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f atom1, agent1 \u0438 ref1 \u043d\u0430 0.<\/p>\n<p>  \u041f\u043e\u043a\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430\u043c\u0438 \u043d\u0435 \u0432\u0438\u0434\u043d\u0430, \u043e\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f.<\/p>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:  <\/p>\n<pre><code class=\"lisp\">(defn atom1-change [] \t(prn &quot;atom1-change&quot;) \t(swap! atom1 inc) \t(prn @atom1))\t  (defn agent1-change [] \t(prn &quot;agent1-change&quot;) \t(send agent1 inc) \t(prn @agent1))  (defn ref1-change [] \t(prn &quot;ref1-change&quot;) \t(dosync \t\t(alter ref1 inc)) \t(prn @ref1)) <\/code><\/pre>\n<p>  \u0412\u044b\u0437\u043e\u0432\u0435\u043c \u0438\u0445:  <\/p>\n<pre><code class=\"lisp\">\t (atom1-change) ;&quot;atom1-change&quot; ;1  (prn @atom1) ;1  (agent1-change) ;&quot;agent1-change&quot; ;0  (prn @agent1) ;1  (ref1-change) ;&quot;ref1-change&quot; ;1  (prn @ref1) ;1 <\/code><\/pre>\n<p>  \u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u0433\u0435\u043d\u0442\u0430 (send agent1 inc) \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e. \u042d\u0442\u0438\u043c \u0430\u0433\u0435\u043d\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445.<\/p>\n<p>  \u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0435\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 Sleep \u0438\u0437 .Net \u0438 \u0443\u0432\u0438\u0434\u0438\u043c interop \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438.   <\/p>\n<pre><code class=\"lisp\">(defn sleep [ms]  \t(. System.Threading.Thread (Sleep ms)))  <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443.  <\/p>\n<pre><code class=\"lisp\">(defn agent1-thread[x]  \t(sleep 1000) \t(send *agent* agent1-thread) \t(prn x) \t(inc x))  (send agent1 agent1-thread) <\/code><\/pre>\n<p>  *agent* \u044d\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0430\u0433\u0435\u043d\u0442.<br \/>  \u0422\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f (\u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c), \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 sleep \u0438 send, \u0441\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0435. \u0412\u0435\u0434\u044c send \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e, \u043f\u043e\u0442\u043e\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043b\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0438 \u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0430\u0442\u044c\u0441\u044f, \u043e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"lisp\">(defn agent1-thread[x]  \t(send *agent* agent1-thread) \t(sleep 1000) \t(prn x) \t(inc x))  (send agent1 agent1-thread) <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u0433\u0440\u0430\u0431\u043b\u0438, \u043e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u043e\u0447\u043a\u0430 (inc x) \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0435\u0441\u044f \u0432 \u0430\u0433\u0435\u043d\u0442\u0435, \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043d\u0430 1 \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0430\u0433\u0435\u043d\u0442.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0440\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c Clojure \u043d\u0430 \u043f\u043e\u043b \u0441 \u044d\u043a\u0441\u0435\u043f\u0448\u043d \u0441\u0442\u044d\u043a \u043e\u0432\u0435\u0440\u0444\u043b\u043e\u0443:<\/p>\n<pre><code class=\"lisp\">(reset! atom1 atom1)  (dosync (ref-set ref1 ref1))  (send agent1 (fn [_] agent1)) <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0430\u0442\u043e\u043c\u0430 \u0440\u0435\u0444\u0430 \u0438 \u0430\u0433\u0435\u043d\u0442\u0430 \u0438\u0445 \u0441\u0430\u043c\u0438\u0445. \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0441\u0442\u044d\u043a \u043e\u0432\u0435\u0440\u0444\u043b\u043e\u0443.<\/p>\n<p>  \u0427\u0430\u0441\u0442\u043e \u0430\u0433\u0435\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u0438\u0445 \u0430\u0433\u0435\u043d\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"lisp\">(def timer (agent nil) ) (defn on-timer [_]  \t(sleep 1000) \t(send *agent* on-timer) \t(prn &quot;tic-tac&quot;))  (send timer on-timer) <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e prn \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 nil \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043d\u0438\u043b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430.<br \/>  \u0422\u0430\u043a \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f send \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0430\u043c \u0430\u0433\u0435\u043d\u0442, \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0432 \u043d\u043e\u0433\u0443:<\/p>\n<pre><code class=\"lisp\">(def timer (agent nil) ) (defn on-timer [_]  \t(sleep 1000) \t(prn &quot;tic-tac&quot;) \t(send *agent* on-timer))  (send timer on-timer) <\/code><\/pre>\n<p>  \u0418 \u0442\u0443\u0442, \u0432\u0440\u043e\u0434\u0435 \u0431\u044b, \u0434\u0430\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0435\u043c\u0443 \u0440\u0430\u0432\u0435\u043d timer, \u0430 \u0440\u0430\u0432\u0435\u043d \u043e\u043d \u0441\u0442\u044d\u043a \u043e\u0432\u0435\u0440\u0444\u043b\u043e\u0443 \u0441 \u043f\u0430\u0434\u0435\u043d\u0438\u0435\u043c Clojure.<\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"lisp\">(def agent1 (agent nil)) (def agent2 (agent nil))\t (def timer (agent nil))  (def atom1 (atom 0)) (def atom2 (atom 0))  (defn atoms-change-thread1 [_] \t(reset! atom1 1) \t(sleep (rand-int 90)) \t(reset! atom2 2) \t(sleep (rand-int 90)) \t(send *agent* atoms-change-thread1) \tnil)  (defn atoms-change-thread2 [_] \t(reset! atom1 3) \t(sleep (rand-int 90)) \t(reset! atom2 4) \t(sleep (rand-int 90)) \t(send *agent* atoms-change-thread2) \tnil)\t  (defn on-timer [_] \t(prn @atom1 @atom2) \t(sleep 1000) \t(send *agent* on-timer) \tnil)   (send agent1 atoms-change-thread1) (send agent2 atoms-change-thread2) (send timer on-timer) <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0434\u0432\u0430 \u0430\u0442\u043e\u043c\u0430 \u0438 \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0438\u0445 \u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<br \/>  \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043f\u0438\u0448\u0435\u0442 \u0432 \u0430\u0442\u043e\u043c\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 1 \u0438 2, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 3 \u0438 4.<br \/>  \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0442\u043e\u043c\u043e\u0432.<br \/>  \u0412\u044b\u0432\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439:<\/p>\n<p>  3 4<br \/>  1 2<br \/>  1 4<br \/>  3 2<br \/>  1 2<br \/>  3 4<br \/>  1 4<br \/>  3 2<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u0445. \u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0430\u0442\u043e\u043c\u043e\u0432 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0444\u044b.<\/p>\n<pre><code class=\"lisp\">(def agent1 (agent nil)) (def agent2 (agent nil))\t (def timer (agent nil))  (def ref1 (ref 0)) (def ref2 (ref 0))  (defn refs-change-thread1 [_] \t(dosync  \t\t(ref-set ref1 1) \t\t(sleep (rand-int 90)) \t\t(ref-set ref2 2) \t\t(sleep (rand-int 90))) \t(send *agent* refs-change-thread1) \tnil)  (defn refs-change-thread2 [_] \t(dosync \t\t(ref-set ref1 3) \t\t(sleep (rand-int 90)) \t\t(ref-set ref2 4) \t\t(sleep (rand-int 90))) \t(send *agent* refs-change-thread2) \tnil)  (defn on-timer [_] \t(prn @ref1 @ref2) \t(sleep 1000) \t(send *agent* on-timer) \tnil)   (send agent1 refs-change-thread1) (send agent2 refs-change-thread2) (send timer on-timer) <\/code><\/pre>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439<br \/>  3 4<br \/>  3 4<br \/>  1 2<br \/>  3 4<br \/>  1 2<br \/>  3 4<br \/>  1 2<br \/>  3 4<br \/>  3 4<br \/>  1 2<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0437\u0430\u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c dosync. \u042d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0446 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0444\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e. \u042d\u0442\u0438\u043c \u043e\u043d\u0438 \u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445.<\/p>\n<p>  \u0425\u043e\u0442\u044f, \u0435\u0441\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0435\u0444\u044b \u043d\u0430 \u0430\u0433\u0435\u043d\u0442\u044b \u043c\u044b \u0442\u043e\u0436\u0435 \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u044c. \u0410\u0433\u0435\u043d\u0442\u044b \u0442\u0430\u043a\u0436\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 STM \u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0430\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0433\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"lisp\">(def agent1 (agent nil)) (def agent2 (agent nil))\t (def timer (agent nil))  (def agent3 (agent 0)) (def agent4 (agent 0))  (defn agents-change-thread1 [_] \t(send agent3 (fn [_] 1)) \t(sleep (rand-int 90)) \t(send agent4 (fn [_] 2)) \t(sleep (rand-int 90)) \t(send *agent* agents-change-thread1) \tnil)  (defn agents-change-thread2 [_] \t(send agent3 (fn [_] 3)) \t(sleep (rand-int 90)) \t(send agent4 (fn [_] 4)) \t(sleep (rand-int 90)) \t(send *agent* agents-change-thread2) \tnil)  (defn on-timer [_] \t(prn @agent3 @agent4) \t(sleep 1000) \t(send *agent* on-timer) \tnil)   (send agent1 agents-change-thread1) (send agent2 agents-change-thread2) (send timer on-timer) <\/code><\/pre>\n<p>  1 2<br \/>  3 4<br \/>  1 2<br \/>  1 2<br \/>  3 4<br \/>  1 2<br \/>  1 2<br \/>  1 2<\/p>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a\u0443. \u0415\u0441\u043b\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"lisp\">(def v [1 1 0 0 0]) (def world (vec  \t(map  \t\t(fn [x] (ref x)) \tv))) (defn place [x] (world x)) (def agent1 (agent 0)) (def agent2 (agent 1)) (def agent-show-world (agent nil))  (defn agent-change [x] \t(let [old (place x) \t  new-coord (rand-int (count world))\t \t  new (place new-coord)] \t(sleep (rand-int 50)) \t(if (= @old 1) \t(do \t\t(send *agent* agent-change) \t\t(dosync \t\t\t(if (= @new 0) \t\t\t\t(do \t\t\t\t\t(ref-set old 0) \t\t\t\t\t(ref-set new 1) \t\t\t\t\tnew-coord) \t\t\t\tx))) \t(prn &quot;agent &quot; *agent* &quot;is out&quot;)))) \t (defn show-world [_] \t(sleep 1000) \t(send *agent* show-world) \t(prn (map (fn [x] (deref x)) world)))  (send agent-show-world show-world) (send agent1 agent-change) (send agent2 agent-change) <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439<br \/>  (1 0 0 1 0)<br \/>  (0 0 1 1 0)<br \/>  (1 0 0 1 0)<br \/>  (0 1 1 0 0)<br \/>  (0 0 1 1 0)<br \/>  (1 0 0 1 0)<br \/>  (0 0 1 1 0)<br \/>  (0 0 1 1 0)<br \/>  (1 0 1 0 0)<br \/>  (1 0 0 1 0)<br \/>  (0 0 1 0 1)<br \/>  (0 1 0 1 0)<br \/>  (1 0 1 0 0)<br \/>  (1 0 0 1 0)<br \/>  (0 0 0 1 1)<br \/>  (0 1 1 0 0)<br \/>  (1 1 0 0 0)<br \/>  (1 0 1 0 0)<br \/>  (0 0 0 1 1)<br \/>  (1 0 1 0 0)<br \/>  (1 0 0 0 1)<br \/>  (1 0 0 1 0)<br \/>  (0 1 0 0 1)<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0432\u0435\u043a\u0442\u043e\u0440 v \u0432 \u043d\u0435\u043c \u0434\u0432\u0430 \u043f\u0435\u0440\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u2014 \u043d\u0443\u043b\u0438. \u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u2014 \u044d\u0442\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u0438, \u0430 \u043d\u0443\u043b\u0438 \u2014 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438. \u0421\u0434\u0435\u043b\u0430\u043b\u0438 \u0432\u0435\u043a\u0442\u043e\u0440 world \u2014 \u044d\u0442\u043e \u0432\u0435\u043a\u0442\u043e\u0440 \u0440\u0435\u0444\u043e\u0432, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u0430 v. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0430\u0433\u0435\u043d\u0442\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432\u0435\u043a\u0442\u043e\u0440\u0430 world. \u0418 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u043f\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0443 world. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u043d\u0435 \u0437\u0430\u043f\u0438\u0448\u0443\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u043a\u043b\u0435\u0442\u043a\u0443.<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u044c, \u043d\u043e \u0438 \u0447\u0442\u0435\u043d\u0438\u0435-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430:<\/p>\n<pre><code class=\"lisp\">(dosync \t(if (= @new 0) \t\t(do \t\t\t(ref-set old 0) \t\t\t(ref-set new 1) \t\t\tnew-coord) \t\tx))) <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043f\u043e \u043d\u043e\u0432\u043e\u0439, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u043e\u0439, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f 0, \u0442.\u0435. \u043f\u0443\u0441\u0442\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430, \u0442\u043e\u0433\u0434\u0430 \u043f\u0438\u0448\u0435\u043c \u0432 \u0441\u0442\u0430\u0440\u0443\u044e \u044f\u0447\u0435\u0439\u043a\u0443 0, \u0430 \u0432 \u043d\u043e\u0432\u0443\u044e 1. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u043c\u0443\u0440\u0430\u0432\u044c\u044f \u0438\u0437 \u0441\u0442\u0430\u0440\u043e\u0439 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432 \u043d\u043e\u0432\u0443\u044e.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0432 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u044c, \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e.<\/p>\n<pre><code class=\"lisp\">(defn agent-change [x] \t(let [old (place x) \t  new-coord (rand-int (count v))\t \t  new (place new-coord)] \t(sleep (rand-int 50)) \t(if (= @old 1) \t(do \t\t(send *agent* agent-change) \t\t(if (= @new 0) \t\t\t(do \t\t\t\t(dosync \t\t\t\t\t(ref-set old 0) \t\t\t\t\t(ref-set new 1)) \t\t\t\tnew-coord) \t\t\tx)) \t(prn &quot;agent &quot; *agent* &quot;is out&quot;)))) <\/code><\/pre>\n<p>  \u0421 \u0442\u0430\u043a\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0432\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439:<br \/>  (0 0 0 1 1)<br \/>  (1 0 1 0 0)<br \/>  (0 0 1 0 1)<br \/>  (1 0 0 0 1)<br \/>  \u00abagent \u00bb #&lt;Agent@549043: 4&gt; \u00abis out\u00bb<br \/>  (1 0 0 0 0)<br \/>  (0 0 1 0 0)<br \/>  (0 0 1 0 0)<br \/>  (0 1 0 0 0)<br \/>  (0 0 0 1 0)<br \/>  (0 0 1 0 0)<\/p>\n<p>  \u0422.\u0435. \u043f\u043e\u0442\u043e\u043a\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e\u0436\u0435 \u043c\u0435\u0441\u0442\u043e, \u043f\u043e\u0442\u043e\u043c \u043e\u0434\u0438\u043d \u043f\u043e\u0442\u043e\u043a \u0443\u0433\u043d\u0430\u043b \u044d\u0442\u0443 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432 \u043d\u043e\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0441\u0432\u043e\u0435\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u043d\u0430 \u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0433\u0434\u0435 \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0438 \u0441\u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f. \u0412\u0441\u0435. \u0411\u044b\u043b \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u043e. \u0412\u0435\u0440\u043d\u0435\u0435 \u0434\u0432\u0430 \u043c\u0443\u0440\u0430\u0432\u044c\u044f \u0441\u043b\u0438\u043b\u0438\u0441\u044c \u0432\u043e\u0435\u0434\u0438\u043d\u043e.<\/p>\n<p>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u0432\u0441\u0435.<\/p>\n<p>  \u041a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430:<\/p>\n<pre><code class=\"lisp\">(def ant-vert-bitmap \t\t\t\t\t\t'(0 0 0 0 0 0 0 0 0 2 2 0 0 0 1 1 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 1 1 0 2 2 2 2 0 1 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 0 0 1 2 3 3 2 1 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 1 2 2 1 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 1 0 0 0 0 1 5 5 1 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 0 0 0 1 4 4 1 0 0 0 1 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 1 0 0 0 1 1 0 0 0 1 0 1 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 1 0 1 5 5 1 0 1 0 0 0 1 0 0 \t\t\t\t\t\t0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 1 0 0 0 0 1 4 4 1 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 1 5 5 5 5 1 0 0 0 1 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 1 5 5 5 5 1 1 1 0 0 1 0 0 \t\t\t\t\t\t0 0 0 0 0 1 1 1 5 4 4 5 1 0 0 1 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 1 0 0 0 \t\t\t\t\t\t0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 \t\t\t\t\t\t0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))  (def ant-diag-bitmap \t\t\t\t\t\t'(0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 2 1 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 2 2 1 0 1 \t\t\t\t\t\t0 0 0 0 0 0 0 0 1 0 0 0 1 5 5 1 1 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 1 0 0 0 1 4 5 1 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 1 0 1 1 1 5 1 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 1 0 0 0 1 1 1 5 4 1 1 0 0 0 0 0 0 0 \t\t\t\t\t\t0 1 0 1 0 1 5 5 5 1 5 1 0 1 1 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 5 5 5 5 5 1 0 0 0 0 1 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 5 4 5 5 5 1 1 1 1 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 5 4 4 5 5 1 0 0 1 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 1 5 5 5 5 1 0 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 \t\t\t\t\t\t0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043c\u0443\u0440\u0430\u0432\u0435\u0439. \u0415\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0438 \u0444\u043b\u0438\u043f\u0430 \u044d\u0442\u0438\u0445 \u043c\u0430\u0442\u0440\u0438\u0446. \u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u0432 .Net Bitmap:<\/p>\n<pre><code class=\"lisp\">(defn render-bitmap [bitmap bit color] \t(let [bit-pos (positions #{bit} bitmap) \t\t  rendered-bitmap (Bitmap. bitmaps-dim bitmaps-dim)] \t(doseq [b bit-pos]  \t\t(let [dy (quot b bitmaps-dim) \t\t\t  dx (rem b bitmaps-dim)] \t\t(.SetPixel rendered-bitmap dx dy color))) \trendered-bitmap)) <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043a\u044d\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u041f\u0440\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435 \u043a\u0430\u0434\u0440\u0430 \u0432\u0441\u0435 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u044d\u0448\u0430.<\/p>\n<p>  \u041d\u0443 \u0438 \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f Windows Form \u0438 Chart \u0442\u043e \u0432\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"lisp\">(def current-wins (atom nil)) (def win-app (agent nil)) (def winforms-app-inited? (atom false))  (def chart (atom nil)) (def series (atom nil))  (defn get-series [series-name] \t(first (filter  \t\t(fn [x]  \t\t\t(if (= (. x Name) series-name) true false)) @series))) \t\t\t (defn add-xy [series-name x y] \t(let [series (get-series series-name)] \t(when series \t\t(.AddXY (.Points series) x y) \t\t(when (&gt; (.Count (.Points series)) 500) (.RemoveAt (.Points series) 0)))))\t\t\t  (defn create-series [chart]\t \t(let  \t\t[series1 (. chart Series)] \t(.Add series1 &quot;herb&quot;) \t(.Add series1 &quot;sugar&quot;) \t(.Add series1 &quot;anthill-sugar&quot;) \t(.Add series1 &quot;aphises&quot;)  \t(doseq [s series1] \t\t(doto s  \t\t\t(.set_ChartType SeriesChartType\/Spline) \t\t\t(.set_IsVisibleInLegend true) \t\t\t)) \t(reset! series series1)\t \t(doto (get-series &quot;herb&quot;) \t\t(.set_Color Color\/Green) \t\t(.set_LegendText &quot;Herb&quot;) \t\t) \t(doto (get-series &quot;sugar&quot;) \t\t(.set_Color Color\/White) \t\t(.set_LegendText &quot;Free sugar&quot;) \t\t) \t(doto (get-series &quot;anthill-sugar&quot;) \t\t(.set_Color (Color\/FromArgb 255 115 61 0)) \t\t(.set_LegendText &quot;Anthill sugar&quot;) \t\t)   \t(doto (get-series &quot;aphises&quot;) \t\t(.set_Color (ControlPaint\/Light Color\/Green)) \t\t(.set_LegendText &quot;Aphises&quot;) \t\t)))  \t  (defn chart-update[chart] \t(add-xy &quot;anthill-sugar&quot; @world-time (anthill-sugar-calc)) \t(add-xy &quot;herb&quot; @world-time (herb-calc)) \t(add-xy &quot;sugar&quot; @world-time (free-sugar-calc)) \t(add-xy &quot;aphises&quot; @world-time (count @aphises)) \t \t(let [chart-areas (. chart ChartAreas) \t\t  chart-area (first chart-areas) \t\t  axis-x (. chart-area AxisX)] \t\t(doto axis-x  \t\t\t(.set_Minimum (if (&gt; @world-time 500) (- @world-time 500) 0)) \t\t\t(.set_Maximum (if (&gt; @world-time 500) @world-time 500))))) \t\t (defn create-form [] \t(let [form (Form.) \t\t  panel (Panel.) \t\t  animation-timer (Timer.) \t\t  world-timer (Timer.) \t\t  chart1 (Chart.) \t\t  series1 (. chart1 Series)] \t(doto chart1 \t\t(.set_Name &quot;chart1&quot;) \t\t(.set_Location (new Point size 0)) \t\t(.set_Size (Size. size size)) \t\t(.set_BackColor (ControlPaint\/Light  bgcolor)))  \t(.Add (. chart1 ChartAreas) &quot;MainChartArea&quot;) \t(.Add (. chart1 Legends) &quot;Legend&quot;) \t \t(doto (first (. chart1 ChartAreas)) \t\t(.set_BackColor bgcolor)) \t \t(doto (first (. chart1 Legends)) \t\t(.set_BackColor bgcolor)) \t\t \t(create-series chart1) \t(reset! chart chart1) \t(chart-update chart1) \t \t(let [chart-areas (. chart1 ChartAreas) \t\t  chart-area (first chart-areas) \t\t  axis-x (. chart-area AxisX) \t\t  axis-y (. chart-area AxisY)] \t(doto axis-x (.set_IsStartedFromZero true)) \t(doto axis-y (.set_IsStartedFromZero true)))  \t(doto panel \t\t(.set_Location (new Point 0 0)) \t\t(.set_Name &quot;panel1&quot;) \t\t(.set_Size (Size. size size)) \t\t(.add_Click  \t\t\t(gen-delegate EventHandler [sender args] \t\t\t\t(when (= (.Button args) MouseButtons\/Right) \t\t\t\t\t(swap! show-lens? (fn [x] (not x)))) \t\t\t\t(when (= (.Button args) MouseButtons\/Left) \t\t\t\t\t(let   [mouse-x (@mouse-pos 0) \t\t\t\t\t\t\tmouse-y (@mouse-pos 1) \t\t\t\t\t\t\tx (\/ mouse-x scale) \t\t\t\t\t\t\ty (\/ mouse-y scale) \t\t\t\t\t\t\tp (place [x y])] \t\t\t\t\t(prn [x y] @p) \t\t\t\t\t(.Focus panel))))) \t\t(.add_MouseMove  \t\t\t(gen-delegate MouseEventHandler [sender args] \t\t\t\t(reset! mouse-pos [ \t\t\t\t\t(* (quot (.X args) scale) scale) \t\t\t\t\t(* (quot (.Y args) scale) scale)]))) \t\t(.add_MouseWheel  \t\t\t(gen-delegate MouseEventHandler [sender args] \t\t\t\t(let [f (fn [x]  \t\t\t\t\t\t\t(let  \t\t\t\t\t\t\t\t[new-sleep  (+ x (* 50 (\/ (.Delta args) 120)))] \t\t\t\t\t\t\t(if (&gt; new-sleep 0) new-sleep 0)))] \t\t\t\t(swap! ant-sleep-ms f) \t\t\t\t(swap! ladybug-sleep-ms f) \t\t\t\t(swap! aphis-sleep-ms f) \t\t\t\t(prn @ant-sleep-ms))))) \t\t\t\t \t(doto animation-timer \t\t(.set_Interval animation-sleep-ms) \t\t(.set_Enabled true) \t\t(.add_Tick (gen-delegate EventHandler [sender args] \t\t\t(do \t\t\t \t\t\t\t(when @buf-graph  \t\t\t\t\t(.Render (@buf-graph 0) (@buf-graph 1))) \t\t\t\t(reset! rectangles-in-cells []) \t\t\t\t(reset! rendered-bitmaps []) \t\t\t\t(let [v (vec (for [x (range dim) y (range dim)]  \t\t\t\t\t\t\t\t@(place [x y])))] \t\t\t\t(dorun  \t\t\t\t\t(for [x (range dim) y (range dim)] \t\t\t\t\t\t(render-place (v (+ (* x dim) y)) x y))) \t\t\t\t(reset! buf-graph (render panel)) \t\t\t\t(when @show-lens?  \t\t\t\t\t(reset! buf-graph (render-lens)))))))) \t\t\t\t\t \t(doto world-timer \t\t(.set_Interval 5000) \t\t(.set_Enabled true) \t\t(.add_Tick (gen-delegate EventHandler [sender args] \t\t\t(swap! world-time inc) \t\t\t(chart-update chart1))))\t\t\t \t\t\t\t\t \t(doto (.Controls form) \t\t(.Add panel) \t\t(.Add chart1)) \t(doto form \t\t(.set_ClientSize (Size. (* size 2)  size)) \t\t(.set_Text &quot;Super Ants&quot;)) \tform))  (defn init-winforms-app []     (when-not @winforms-app-inited? \t   (Application\/EnableVisualStyles) \t   (Application\/SetCompatibleTextRenderingDefault false)        (reset! winforms-app-inited? true))) \t    (defn start-gui [x]     (init-winforms-app)     (reset! current-wins (create-form))     (Application\/Run @current-wins)) <\/code><\/pre>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0431\u044b\u043b\u043e \u043d\u0435 \u0441\u043a\u0443\u0447\u043d\u043e.<\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/256017\/\"> http:\/\/habrahabr.ru\/post\/256017\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 Clojure \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0430 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 STM (The software transactional memory system). \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0420\u0438\u0447 \u0425\u0438\u043a\u043a\u0438 (\u0431\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0430\u0432\u0442\u043e\u0440 Clojure) \u0438 \u0414\u044d\u0432\u0438\u0434 \u041c\u0438\u043b\u043b\u0435\u0440 (\u0447\u0435\u043b\u043e\u0432\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e Clojure \u043f\u043e\u0434 .Net) \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u00abants\u00bb, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u0443\u0435\u0442 \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a. \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0442\u0430\u043c \u0436\u0438\u0432\u0435\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u041c\u0443\u0440\u0430\u0432\u044c\u0438 \u0431\u0435\u0433\u0430\u044e\u0442 \u043f\u043e \u043a\u043b\u0435\u0442\u043a\u0430\u043c \u043e\u0431\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f, \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u0435\u0434\u0443, \u043d\u043e\u0441\u044f\u0442 \u0435\u0435 \u0432 \u043c\u0443\u0440\u0430\u0432\u0435\u0439\u043d\u0438\u043a \u0438 \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0432\u043e\u0438\u0445 \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u0439 \u0441 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 \u044f \u0438 \u0445\u043e\u0447\u0443 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043d\u0430 \u043e\u0431\u0449\u0435\u0435 \u043e\u0431\u043e\u0437\u0440\u0435\u043d\u0438\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 Clojure \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 .Net.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-255480","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=255480"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255480\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}