dramforever 2017-02-19 23:45:15
tdammers: Sadly too many are obsessed with making their 3s-run-time network-intensive apps 10us faster, even if it's just about a *claim* that 'strict evaluation is faster than lazy evaluation'
ezyang 2017-02-19 23:53:18
Ooh, programming with Brick is fun
gargawel 2017-02-19 23:57:22
Hi, is there something like a priority queue in base ?
ezyang 2017-02-19 23:59:14
gargawel: Not publically. (There actually is a priority queue for the event manager but you're not supposed to use it)
gargawel 2017-02-20 00:00:59
ezyang: OK. Seems quite surprising.
jophish_ 2017-02-20 00:10:08
Is there a way to install a packages documentation only, so I can browse documentation without building the package?
systadmin 2017-02-20 00:32:32
heyo
quchen 2017-02-20 00:36:22
gargawel: You can easily build a priority queue as a wrapper around a »Map Double a«. Map has an API function to get the element with the largest/lowest index.
quchen 2017-02-20 00:36:40
Map isn't in base, but part of the used-everywhere-de-facto-standard.
systadmin 2017-02-20 00:36:50
Is there a way to remove a certain element from a list?
quchen 2017-02-20 00:36:59
:t delete
lambdabot 2017-02-20 00:37:01
Eq a => a -> [a] -> [a]
systadmin 2017-02-20 00:37:02
Like an expression that removes the 2nd and 4th element?
quchen 2017-02-20 00:37:10
> delete 3 [1..10]
lambdabot 2017-02-20 00:37:13
[1,2,4,5,6,7,8,9,10]
systadmin 2017-02-20 00:37:44
> delete 2, 4 [1, 2, 3, 4]
lambdabot 2017-02-20 00:37:47
quchen 2017-02-20 00:37:50
I don't think there's a standarf function for indexed deletion.
gfixler 2017-02-20 00:38:16
> foldr delete [2,4] [1,2,3,4]
lambdabot 2017-02-20 00:38:22
[]
gfixler 2017-02-20 00:38:25
done
yushyin 2017-02-20 00:38:30
:t deleteBy
lambdabot 2017-02-20 00:38:33
(a -> a -> Bool) -> a -> [a] -> [a]
quchen 2017-02-20 00:39:27
> let deleteNth n xs = let (as,b:bs) = splitAt n xs in as ++ bs in deleteNth 4 "hello world" -- Delete index N.
lambdabot 2017-02-20 00:39:31
"hell world"
gfixler 2017-02-20 00:39:49
guess that should have been reversed
gfixler 2017-02-20 00:39:55
> foldr delete [1,2,3,4] [2,4]
lambdabot 2017-02-20 00:39:58
[1,3]
systadmin 2017-02-20 00:40:42
:t foldr
quchen 2017-02-20 00:40:45
systadmin: You can write the function yourself as an exercise.
lambdabot 2017-02-20 00:40:46
Foldable t => (a -> b -> b) -> b -> t a -> b
gfixler 2017-02-20 00:40:55
what about take and drop?
quchen 2017-02-20 00:41:20
It's similar to how »drop« and »take« are implemented, only that you're not dropping everything up to/beginning from your element.
gfixler 2017-02-20 00:41:39
> let x = 3 in xs = [0..9] in take x xs ++ drop x xs
lambdabot 2017-02-20 00:41:45
lambdabot 2017-02-20 00:41:45
parse error on input '='
lambdabot 2017-02-20 00:41:45
Perhaps you need a 'let' in a 'do' block?
gfixler 2017-02-20 00:41:46
> let x = 3, xs = [0..9] in take x xs ++ drop x xs
lambdabot 2017-02-20 00:41:51
gfixler 2017-02-20 00:41:57
> let x = 3; xs = [0..9] in take x xs ++ drop x xs
lambdabot 2017-02-20 00:42:01
[0,1,2,3,4,5,6,7,8,9]
gfixler 2017-02-20 00:42:05
I give up
gfixler 2017-02-20 00:42:22
> let x = 3; xs = [0..9] in take x xs ++ drop (x + 1) xs
lambdabot 2017-02-20 00:42:26
[0,1,2,4,5,6,7,8,9]
quchen 2017-02-20 00:42:28
?check \n xs -> xs == take n xs ++ drop n (xs :: Int)
lambdabot 2017-02-20 00:42:31
error:
lambdabot 2017-02-20 00:42:32
• Couldn't match expected type 'Int' with actual type '[()]' • In the second...
quchen 2017-02-20 00:43:09
?check \n xs -> xs == take n xs ++ drop n (xs :: [Int])
lambdabot 2017-02-20 00:43:13
+++ OK, passed 100 tests.
quchen 2017-02-20 00:43:14
Take plus drop is id :-)
gfixler 2017-02-20 00:43:20
:)
quchen 2017-02-20 00:44:25
gfixler: And splitAt n xs = (take n xs, drop n xs)
quchen 2017-02-20 00:44:30
(But more efficient)