Saltar al contenido ForoHackers

Haskell: why did length [Nothing, Nothing] give me two?

Estructuras de datosDepuraciónHaskell
#18574 · · Citar · Denunciar

rebuilding a type specimen drawer, very small Haskell list. two positions I'm missing are both Nothing. length [Nothing, Nothing] gives 2. I do understand that two is a number. is there a way to make it count the actual bloody letters?

#18909 · · Citar · Denunciar

length counted your two placeholders. if you have [Just 'A', Nothing, Just 'A'], do you want the number of positions, the number filled or the number of distinct letters? you managed to pick a drawer which gives three different answers.

#18910 · · Citar · Denunciar

3, 2, 1. Filled only today. I want to charge the buyer for two metal pieces, not a spiritually complete alphabet.

#18911 · · Citar · Denunciar

A list comprehension can select the Just cases: length [c | Just c <- xs]. It doesn't modify the drawer. Two A sorts genuinely are two pieces.

#18912 · · Citar · Denunciar

two for that drawer, zero for the original. keeping the Nothing positions matters for the person putting the type away. took my lunch next to a man who could tell you which seats were empty and still pay for the correct number of sandwiches. impressive.

#18913 · · Citar · Denunciar

Vente al hilo del malware. El bocadillo once lo hemos mirado dos veces y todavía no se ha atrevido nadie a comérselo.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder