You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
ã¯ããã« ãç¡æ²æ±°ãã¦ããã¾ããç°ä¸ã§ããä»å㯠jq 㨠JMESpath ã«ã¤ãã¦æ¸ãã¾ãã AWS CLI ã®è¿ãå¤ã® JSON ã¯ã以ä¸ã®ããã« --query ãªãã·ã§ã³ã« JMESPath ãæå®ãã¦å¦çã§ãã¾ãã # ååã test- ã§å§ã¾ãææ°ã® AMI ã® id ãåå¾ $ aws ec2 describe-images \ --filters Name=state,Values=available Name=is-public,Values=false \ --query "Images[?starts_with(Name, 'test-')] | sort_by(@, &CreationDate) | reverse(@)[0].ImageId" "ami-xxxxxxxxxxxxxxxxx"
å¯å¤ãªã«ã¼ãæ§é ãå¿ è¦ã¨ããåé¡*1ã«é¢ãã¦ã¯ãå帰ãã¹ã¿ãã¯ã使ã£ã¦å¯å¤ãªã«ã¼ãæ§é ã«å¯¾å¿ããã®ãããã°ã©ãã³ã°ã®å¸¸å¥æ段ã§ããããã®ãããªæ段ãããããå¿ è¦ã«ãªãã®ã¯ãforæãåçã«å¢ãããªãã¨ããåé¡ã«çµ¡ãã§ãã¾ããããããforæãåçã«å¢ããã°ããã®ã§ã¯ãªãããã¨èããããããã¾ããããCãJavaãªã©ã®evalããªãè¨èªã§ã¯ãããªãã¨ã§ãã¾ããã ã¨ãããæãã®Lispã«ã¯evalãããã¾ããããããã¼ã¿æ§é ãããã°ã©ã ããã¹ãã§ãããããåçã«ããã°ã©ã ããã¹ããçæãã¦ãä¸èªç¶ã«è¦ãã¾ãã*2ãããã§ã¯ãnåã®éåããç´ç©éåãçæããé¢æ°ãä¾ã«ã¨ã£ã¦èãã¾ãããã ç´ç©éåã¨ã¯{1,2}ã¨{3,4}ããçæããã{(1,3), (2,4)}{(1, 3), (1, 4), (2, 3), (2, 4)}ãã¨ãè¨ãã¾ãã詳ããã¯Wikipediaãåç §ãã¦ãã ããã é常
åè 1段ãã¹ããããªã¹ããflattenããæ¹æ³ Making a flat list out of list of lists in Python - Stack Overflow 2段以ä¸ãã¹ããããªã¹ããflattenããæ¹æ³ Flatten (an irregular) list of lists in Python - Stack Overflow Right Foot In: More on python flatten è²ã æ¹æ³ãããã¿ãããªã®ã§æ¸çãã 1段ãã¹ããããªã¹ããflattenããã¨ã¯ ã¤ã¾ãã l = [[1,2,3],[4,5,6], [7], [8,9]] ã [1,2,3,4,5,6,7,8,9] ã«ããã¨ãããã¨ã reduceã使ã£ãæ¹æ³ reduceã使ã£ã¦ãªã¹ããç³ã¿è¾¼ããã¨ãã§ããã reduce(lambda x,y: x+y,l) çµè¾¼ã¿
def flatten(ls): """ >>> flatten([1, [2, 3], [4], 5, [6, [7]]]) [1, 2, 3, 4, 5, 6, 7] """ return sum((flatten(i) for i in ls), []) if isinstance(ls, list) else [ls] 大ãã¦å¤ãããªãã¨æããã©ãflattenåããgeneratorãsumããã®ã¨ãreduceããã®ã¨ã©ã£ã¡ãå¹çãããã®ã ãããï¼ def flatten(ls): if not isinstance(ls, list): return [ls] return reduce(lambda s, i: s + flatten(i), ls, []) generatorçfaltten def flatten(ls): """ >>> list(flatten([1
JavaScriptã§ãªã¹ãå å 表è¨ã®ãããªäºããã£ã¦ã¿ããã ãã®çºã«ã¾ããã«ã«ãç©ãã¨ãçºã®å¦çãä½æãã¦ã¿ãã ãã«ã«ãç©ã£ã¦ï¼ ãã«ã«ãç©ã¨ã¯ç´ç©ã¨ãå¼ã°ãè±èªã§ã¯product Cartesian product ã¨ããããã ã ä¾ãã°[1,2,3]ã¨ããéå㨠[4,5,6] ã¨ããéåãããã¨ã ãããã®ãã«ã«ãç©ã¯ [1,4],[1,5],[1,6],[2,4],[2,5],[2,6],[3,4],[3,5],[3,6] ã¨ãªããè¦ããã«å ¨ã¦ã®çµã¿åããã¨ããäºã ããã¨è¦ãæãåç´ã«ï¼æ¬¡å é åã«ãã¦ãã«ã¼ãããã¹ãã«ããã ãã§è¯ãããã ãããã£ãããªã®ã§é¢æ°æåçã«æ¸ãã¦ã¿ããã ã¾ãï¼æ¬¡å ç®ã®é å [4,5,6] ã«ä½ããã®å¦çãé©ç¨ããäºã§ã [4,5,6] -> [ [1,4],[1,5],[1,6] ] ã¨å¤åããå¦çãå¿ è¦ã ä½ããã®å¦çã¨ã¯åºå®ããã1ã¨ããã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}