Comments (7)
O čem je tu govora, ker se zdi precej sumljivo.
from funkcionali-izbire.
V 5. vrstici datoteke zapiski.txt vrneva 1. Vrniti pa morava neki element iz S, ker funkcija izbire izbira elemente iz S.
(Ker denes v prvih 15h sekundah nisva našla načina, kako odpreti issue tik ob datoteki ipd, sva ga pač samo odprla kot opozorilo, kaj morava popraviti.)
from funkcionali-izbire.
A je vseeno, kateri element, samo da je en element iz S
? V tem primeru je najbolje, če definirata type class Pointed
:
class Pointed t where
point :: t
Potem enostavno vrneta point
. Seveda je treba tudi definirati instance
, recimo:
instance Num t => Pointed t where
point = 0
instance Pointed () where
point = ()
instance (Pointed a, Pointed b) => Pointed (a, b) where
point = (point, point)
instance Pointed b -> Pointed (a -> b) where
point = \_ => point
in tako naprej (na pamet pišem kodo, tako da verjetno ne deluje).
from funkcionali-izbire.
Hm. Videti je, kot da je vrednost point
določena že s tipom? Če je tako, potem to ni ok, ker mora biti element, ki ga vrneva, v množici S
, ta pa je zgolj podmnožica v množici Nat
oz. v Nat -> Nat
oz. v (Nat -> Nat) -> Nat
. Ker je tisti element povsem odvisen od množice, ga niti ne moreva definirati rekurzivno, kot je to storjeno zgoraj.
from funkcionali-izbire.
Aha, ok. Izgleda, da ne vem, kaj se dogaja. A je poanta, da se izračuna element S
, ali se bo vedno v naprej vedel neki element S
?
from funkcionali-izbire.
Množica S
je fiksna in neznana, imava eksistenčni kvantifikator zanjo, napisati morava pa funkcijo izbire. Ta dobi predikat p
. Če v S
obstaja kak element, ki zadošča temu predikatu, potem morava vrniti enega od teh, ki zadoščajo, sicer pa poljubnega iz S
(to je ta, o katerem že vseskozi na pol govorimo).
Če v naprej izračunava neki element v S
, privarčujeva čas za izračun nekega vsakič, ko bo p(S) = {False}
. Drugih prednosti ni.
from funkcionali-izbire.
Aha, potem pa predlagam, da vzameta element S
kot input. Tak element je "dokaz", da S
ni prazna množica (oz. da je naseljena).
from funkcionali-izbire.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from funkcionali-izbire.