conf.py
? the sidebar never scrolls unless I get waaaay down in the docs... just a minor pet peeve ^_^ https://github.com/ryan-roemer/sphinx-bootstrap-theme/issues/136#issuecomment-186860368)
globaltoc_depth:3
option? It that does what I'm assuming, then the sidebar would just have less "stuff" in it.
{'q'+n:val} = {'q1':2}
print(n)
CoconutParseError: parsing failed (line 1)
{'q'+n:val} = {'q1':2}
File "<string>", line unknown
SyntaxError: parsing failed
{'q'+n:val} = {'q1':2}
['q'+n, val] = ['q1',2]
print(n)
>>> 1
{('q1',n): '1'+val} = {('q1',2):'12'}
print(n)
yknow what, I literally asked this in 2019 haha. You said:
@tbsexton Dictionary keys in patterns currently have to be constants, unfortunately--there's no current syntax for looking up keys based on values, only for looking up values based on keys. Feel free to raise an issue for that, though.
yeah that's a great point. Though I will say, my workaround was to use tuples which work fine.
It was a bit of an edge-case, perhaps. This was data formed from an OpenAPI schema, so they had a lists of single-pair dicts. [{k1,v1},{k2:v2},...] etc. So I was pattern matching on only one key to dispatch to whatever function needed to be executed on the value for a given key. I knew the dicts were singletons, so it was ok to use match def f(d is dict) = f(d.items()|>list|>.[0])
and do all the logic in tuples
I do have another question: what would the equivalent of yield from
be in terms of maps?
When using a nested lazy sequence, even calling list
on the resulting generator usually returns a list of a bunch of lazy sequences (of possibly unknown depth). Is there a command/pattern for recursively consuming/yielding all generators? I know in the past I used for gen in super-gen: yield from gen
, but alas, this inhibits my quest to be rid of for-loops ^_^
map
/fmap
as opposed to for ... yield from
but i always seem to end up with a top-level list full of un-executed generator functions
|> list
part, rather leaving as a generator. the whole "stack" of generators would get flattened into one generator over the leaves
eval_iters
is doing:def recursive_map(func, () :: it) =
it |> map$(recursive_map$(func)) |> func
addpattern def recursive_map(func, x) = func(x)
def list_it(() :: it) = list(it)
addpattern def list_it(x) = x
eval_iters = recursive_map$(list_it)
(|1, (|2, 3|), 4, (|5, 6|)|) |> eval_iters |> print
--target 3
(or above) and also supports a host of unicode alternatives to built-in operators.
typeclasses
or something, though addpattern
is probably going to be better than any library like that if you're working in Coconut.
toolz
's valmap
function?