전체 글
-
Julia: 거품 정렬 및 로컬 모듈 사용하기컴퓨터 2020. 11. 14. 20:53
Julia The Julia Programming Language Julia julialang.org 1. 로컬 모듈 만들기 module utils # 사용할 모듈 이름 export 🚨, genRandomArray # JS, TS와 비슷하게 export할 메소드들 # 오름차순으로 정렬 확인 함수 function 🚨(A::AbstractVector) for i = 1:length(A) - 1 if A[i] > A[i + 1] return false end end return true end # 랜덤 배열 생성기 function genRandomArray(size::Number) return [rand(-size:size) for _ = 1:size] end end 2. 거품 정렬 위 로컬 모듈을 불러온 후..
-
파이썬: Monad (모나드)컴퓨터/파이썬 2020. 11. 11. 14:34
Monad (단자) Monad (functional programming) - Wikipedia Design pattern in functional programming to build generic types In functional programming, a monad is an abstraction that allows structuring programs generically. en.wikipedia.org Monad란 """ Monad 예제 """ class List: # ...monad... a = List([1.1, 2.6, 3.5]) # a.data = [1.1, 2.6, 3.5] b = a | str | (lambda f: f.zfill(5)) # b.data = ['001.1', '00..
-
TypeScript: Bubble Sort (거품 정렬)컴퓨터/HTML & JS & TS 2020. 11. 8. 21:31
TypeScript Typed JavaScript at Any Scale. TypeScript extends JavaScript by adding types to the language. www.typescriptlang.org # TypeScript 1일차 언어를 공부할 때 정렬 알고리즘부터 시작하는 편이다. Go언어, Python type hinting 버전과 비슷한 느낌이지만, interface, JS 기능들이 많이 미숙하기에 공부가 더 필요 1. 문법 소개 one-line swapping (한 줄로 값 변경) 특이하게, array안에 넣어서 해야한다. (함수에서 두가지를 return 할 때도 return [a, b]로 쓸 수도 있다. [array[i], array[i + 1]] = [array[i..
-
파이썬 Sørensen–Dice coefficient컴퓨터/파이썬 2020. 11. 5. 12:08
Sørensen–Dice coefficient Sørensen–Dice coefficient - Wikipedia The Sørensen–Dice coefficient (see below for other names) is a statistic used to gauge the similarity of two samples. It was independently developed by the botanists Thorvald Sørensen[1] and Lee Raymond Dice,[2] who published in 1948 and 1945 respectiv en.wikipedia.org 1. 쇠렌센-다이스 계수 이 계수는 두 샘플의 유사도를 측정하기 위한 통계량이다. (통계량이기 때문에, "aaba"..
-
Python cProfile + snakeviz 런타임 시각화컴퓨터/파이썬 2020. 11. 4. 15:14
snakeviz jiffyclub/snakeviz An in-browser Python profile viewer. Contribute to jiffyclub/snakeviz development by creating an account on GitHub. github.com 1. 소개 우선 파이썬 내장 모듈인 cProfile은 코드 실행 시간을 보는데 유용하다. (:1()은 무시해도 좋다.) print(cProfile.run("bubbleSort(arr)")) ''' 결과 5 function calls in 2.555 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.0..
-
Python Singly Linked List 함수들컴퓨터/파이썬 2020. 11. 3. 22:22
단일 연결 리스트 연결 리스트 - 위키백과, 우리 모두의 백과사전 위키백과, 우리 모두의 백과사전. ko.wikipedia.org 만들어 볼 것 Magic methods ( lt, gt, pos, repr ) print 함수 add 함수 ( add([1,2,3,4,5] ) getNodesInArray ( head.getNodesInArray() = [1,2,3,4,5] ) linkedify ( [1,2,3,4,5] 배열을 받으면, 1 -> 2 -> 3 -> ...) swap ( a.value, b.value = b.value, a.value) reverse (뒤집기) ( 1 -> 2 -> 3을 3 -> 2 -> 1로) Python sort 함수 이용 정렬 Bubble sort (거품 정렬) Selecti..
-
파이썬 FastAPI로 REST API 구현하기컴퓨터/파이썬 2020. 10. 31. 00:08
FastAPI 카카오 챗봇 서버 예제 1. FastAPI 설치 pip install fastapi pip install uvicorn # 위는 ASGI 서버 2. FastAPI 베이스 기본 틀 from typing import Optional from fastapi import FastAPI from fastapi.encoders import jsonable_encoder app = FastAPI() @app.get("/") async def read_root(): return "Hi" 서버 실행 (main은 main.py, 이름에 맞춰 바꿔준다.) (코드가 수정될 때마다 알아서 새로고침 해준다.) uvicorn main:app --reload 3. JSON 사용할 데이터는 아래와 같다. language..