change raw haxe

This commit is contained in:
Yvon
2022-06-11 22:54:20 +03:00
committed by Nat Quayle Nelson
parent a1853d02e5
commit b975ff2e14
15 changed files with 28 additions and 28 deletions

View File

@@ -8,10 +8,10 @@
(.filter
(for paragraph
(.split
(.replace (File.getContent file) #|"\r"|# "")
#|"\n\n"|#)
(.replace (File.getContent file) "\r" "")
"\n\n")
(.filter
(paragraph.split #|"\n"|#)
(paragraph.split "\n")
(lambda [line] (< 0 line.length))))
(lambda [lines] (< 0 lines.length))))

View File

@@ -34,4 +34,4 @@
(if (stream.isEmpty)
null
`(,(b.symbol (stream.expect "a ship command" ->(stream.takeChars 1)))
,(b.symbol (stream.expect "a number argument" ->(stream.takeUntilAndDrop #|"\n"|#))))))
,(b.symbol (stream.expect "a number argument" ->(stream.takeUntilAndDrop "\n"))))))

View File

@@ -3,7 +3,7 @@
(function :FerrySquare emptySeat [:Array<FerrySquare> n :SeatsChanged changed]
// Empty seats with completely empty neighbors, fill up
(cond
((= true (apply = (for neighbor n #|neighbor != fullSeat|#)))
((= true (apply = (for neighbor n #{neighbor != fullSeat}#)))
(set changed.changed true)
fullSeat)
(true emptySeat)))
@@ -11,7 +11,7 @@
(function :FerrySquare fullSeat [:Array<FerrySquare> n :SeatsChanged changed]
// Full seats with 4 or more full neighbors become empty
(cond
((<= 4 (count n (lambda [neighbor] #|neighbor == fullSeat|#)))
((<= 4 (count n (lambda [neighbor] #{neighbor == fullSeat}#)))
(set changed.changed true)
emptySeat)
(true fullSeat)))
@@ -43,7 +43,7 @@
(for :Array<FerrySquare> row state
(apply +
(for :FerrySquare seat row
(if #|seat == fullSeat|# 1 0))))))
(if #{seat == fullSeat}# 1 0))))))
(defReaderMacro "L" [stream] `emptySeat)
(defReaderMacro "#" [stream] `fullSeat)
@@ -51,4 +51,4 @@
(undefReaderMacro "...")
(defReaderMacro &start "" [stream]
`(state.push ,(ReaderExp.ListExp (readExpArray stream #|"\n"|#))))
`(state.push ,(ReaderExp.ListExp (readExpArray stream "\n"))))

View File

@@ -4,7 +4,7 @@
(let [key (stream.expect "passport key" (lambda [] (stream.takeUntilAndDrop ":")))
value (stream.expect "passport value" (lambda [] (stream.takeUntilOneOf [" " "\n"] true)))]
(dictSet pp key value))
(if (= #|"\n\n"|# (try (stream.expect "paragraph break" (lambda [] (stream.peekChars 2))) (catch [e] "")))
(if (= "\n\n" (try (stream.expect "paragraph break" (lambda [] (stream.peekChars 2))) (catch [e] "")))
(begin (stream.dropWhitespace) pp)
(begin (stream.dropWhitespace) (readPassport stream pp))))

View File

@@ -126,7 +126,7 @@
dist (Adapters.distribution diffs)]
(assert (= 1998 (* (dictGet dist 1) (dictGet dist 3)))))
(let [memoized (memoize Adapters.arrangementCount)]
(set Adapters.arrangementCount #|cast memoized|#))
(set Adapters.arrangementCount #{cast memoized}#))
(assert (= "347250213298688" (Int64.toStr (Adapters.arrangementCount adapters 0))))))
(day 11

View File

@@ -4,7 +4,7 @@
`(let [theMap ,theMap key ,key amount ,amount &mut count (dictGet theMap key)]
(unless count
(dictSet theMap key (set count (Int64Helper.fromFloat 0))))
(dictSet theMap key #|count + amount|#)))
(dictSet theMap key #{count + amount}#)))
// Remove and return an arbitrary key-value pair from the given Map
(function :Array<Dynamic> dictShift [:Map<String,Dynamic> m]

View File

@@ -37,4 +37,4 @@
(function :Int numHotPositions [file &opt :Bool part2]
(let [theMap (ventsByPos file ?part2)
two (Int64Helper.fromFloat 2)]
(count theMap ->vents #| vents >= two |#)))
(count theMap ->vents #{ vents >= two }#)))

View File

@@ -9,7 +9,7 @@
(doFor age list
(let [count (dictGet theMap age)
one (Int64Helper.fromFloat 1)]
(dictSet theMap age #|count + one|#)))
(dictSet theMap age #{count + one}#)))
theMap))
(function :Map<Int,Int64> stepAgeMap [:Map<Int,Int64> theMap]

View File

@@ -178,16 +178,16 @@
(if lastDayDone
(DateTime.fromString lastDayDone)
(let [&mut now (DateTime.fromDate (Date.now))]
(until (= 1 (now.getDay)) #|now -= oneDayInterval;|#)
(until (= 1 (now.getDay)) #{now -= oneDayInterval;}#)
now))]
(until (and (= (nextDay.getDay) (dayToEndSearch.getDay)) (= (nextDay.getMonth) (dayToEndSearch.getMonth)) (= (nextDay.getYear) (dayToEndSearch.getYear)))
(let [daysInMonth (DateTime.daysInMonth (nextDay.getMonth) (nextDay.isLeapYear))
adjustedDays (for day days (% (+ daysInMonth day) daysInMonth))]
(when (contains adjustedDays (nextDay.getDay)) (return true)))
#|nextDay -= oneDayInterval|#)
#{nextDay -= oneDayInterval}#)
(return false)))
((Interval days lastDayDone)
(or !lastDayDone (<= days #|(DateTime.fromDate(Date.now()) - DateTime.fromString(lastDayDone)).getTotalDays()|#)))
(or !lastDayDone (<= days #{(DateTime.fromDate(Date.now()) - DateTime.fromString(lastDayDone)).getTotalDays()}#)))
(Todo (= 0 .points (activeLabel e)))
(otherwise true)))

View File

@@ -18,7 +18,7 @@
(when !(= direction Vector3.ZERO)
(set direction (direction.normalized))
// TODO for some reason, the Vector3 addition operator is only found when used in a raw haxe expr:
(pivot.lookAt #|translation + direction|# Vector3.UP))
(pivot.lookAt #{translation + direction}# Vector3.UP))
(set _velocity.x (* direction.x speed))
(set _velocity.z (* direction.z speed))

View File

@@ -3,7 +3,7 @@
(var TEXT_SIZE 24)
(prop &mut :FlxText docText null)
(method &override :Void create []
#|{
#{
super.create();
var background = new FlxSprite();
@@ -38,7 +38,7 @@
add(actionSprites);
}|#)
}#)
(prop :Map<Int,ArrowDir> inputCodes (new Map))
(var DIR_ORDER [ Left Down Up Right ])
@@ -57,10 +57,10 @@
(set timer (new FlxTimer))
(let [&mut i 0]
(timer.start ARROW_DELAY ->_ {
#|{
#{
var stuff = _model.generateArrowStuff();
makeTriangleSprite(DIR_ORDER[i++ % DIR_ORDER.length], stuff.text, -SPRITE_SIZE, stuff.action);
}|# } 0)))
}# } 0)))
(whenLet [(Some id) (getFirstInputId)
dir (dictGet inputCodes id)]
(let [&mut :ActionSprite lowestMatching null
@@ -98,7 +98,7 @@
(updateDocText))
(method :FlxSprite makeTriangleSprite [:ArrowDir dir :String text :Int y &opt :Void->Void action]
#|{
#{
var spr = new ActionSprite(action, dir);
spr.makeGraphic(SPRITE_SIZE, SPRITE_SIZE, FlxColor.TRANSPARENT, true);
FlxSpriteUtil.beginDraw(FlxColor.WHITE);
@@ -147,4 +147,4 @@
}
return spr;
}|#)
}#)